JDK, JRE, and JVM describe different parts of the Java toolchain. The Java Development Kit supplies development tools such as javac. A runtime environment supplies what is needed to execute Java applications. The Java Virtual Machine loads and executes bytecode with services such as memory management. Understanding these names helps diagnose whether a machine can compile source, run a class, or both. Modern distributions often package runtimes differently, so these terms describe responsibilities more reliably than a promise about separate installers.
The JDK supplies development tools
A JDK includes javac for compiling source and java for launching applications, plus tools such as jar, javadoc, and jdb. Installing a JDK is the usual choice for a learner who will write and compile programs. Running java -version alone proves that a java launcher is available, but it does not prove javac is on the command path. Check both commands when preparing a development machine.
The runtime supplies execution support
A Java runtime includes the components needed to run an application, including a JVM and standard library support. The older term JRE often referred to a separately installed runtime distribution. Modern Java vendors may provide a full JDK, a runtime package, or a custom runtime image made with jlink. Do not assume every current download offers a separate product named JRE. Choose a distribution suited to the application's supported Java version and deployment policy.
The JVM executes compiled bytecode
javac produces class files containing bytecode. The java launcher starts a JVM that loads the requested class, verifies relevant bytecode constraints, and invokes its main entry point. The JVM may interpret code and compile frequently executed code to native machine instructions through just-in-time compilation. You do not manually run javac's output as a native executable; the launcher and runtime supply the execution environment.
The standard library is part of the platform
Classes such as String, ArrayList, and LocalDate provide platform APIs your program can use. The JVM and library versions together affect which bytecode and APIs are supported. A program compiled for a newer release may fail on an older runtime, even when the source looks simple. The --release compiler option helps target a chosen platform release by constraining language level, class-file version, and the available platform API.
Distinguish source portability from runtime compatibility
Java class files are designed to run on compatible implementations across operating systems, but portability is not absolute. Native libraries, filesystem assumptions, environment configuration, and newer APIs can tie an application to particular environments. A class-file version mismatch commonly produces UnsupportedClassVersionError. Check which javac compiled the application and which java is launching it before assuming the source contains a logic bug.
Inspect the actual selected installation
PATH determines which command executable is found first. JAVA_HOME is a conventional environment variable used by many tools, but the java command itself may still come from another PATH entry. This can leave Maven compiling with one JDK while a terminal launches another. Record the version output and selected executable locations when troubleshooting. Use a consistent supported toolchain rather than repeatedly reinstalling Java without checking command resolution.
Practice tasks and checks
Run java -version and javac -version in the same terminal and compare their feature releases. On Windows, inspect command locations with where.exe java and where.exe javac; on systems with an appropriate shell, use command -v. These commands produce environment-specific paths, so record your own output instead of expecting the tutorial's directory. Compile RuntimeVersion with --release 17 and launch it using your chosen java executable. Next, explain which part of the process needs the JDK compiler and which part needs only execution support. Finally, look at the imports in PlatformLibrary and identify the standard API. This exercise should leave you with a clear toolchain diagram, not merely three memorized acronym expansions.
Java Summary
- The JDK provides development tools, while the JVM executes bytecode.
- Inspect both compiler and launcher versions when diagnosing compatibility.
- Platform targeting does not install a missing toolchain.
- Continue with JDK installation when these examples are clear.
Java Examples
Each example shows the code, the output it produces and what each part does.
See the runtime version from a program
Save this program as RuntimeVersion.java. Compile it with javac RuntimeVersion.java and run it with java RuntimeVersion.
Expected output:
Runtime.version describes the runtime executing this program, not necessarily the compiler that produced its class file. feature returns the major feature release. On the lesson's Java 17 baseline or a newer compatible runtime, the comparison prints true. This is a capability check rather than a claim that all future versions behave identically. A real application's supported range should be documented more precisely.
public class RuntimeVersion {
public static void main(String[] args) {
Runtime.Version version = Runtime.version();
System.out.println(version.feature() >= 17);
}
}trueUse a platform API supplied by the runtime
Save this program as PlatformLibrary.java. Compile it with javac PlatformLibrary.java and run it with java PlatformLibrary.
Expected output:
The import makes the standard LocalDate type available by its simple name. No third-party download is needed because java.time is part of the platform. The runtime supplies that class when the bytecode executes. The chosen calendar date has a stable weekday, so the example separates platform support from changing system time. Removing an unnecessary library dependency is different from omitting a required runtime.
import java.time.LocalDate;
public class PlatformLibrary {
public static void main(String[] args) {
System.out.println(LocalDate.of(2024, 8, 12).getDayOfWeek());
}
}MONDAYRead the operating-system property
Save this program as RuntimeProperties.java. Compile it with javac RuntimeProperties.java and run it with java RuntimeProperties.
Expected output:
System properties expose runtime configuration, including the platform's file separator. This example prints a portable boolean rather than promising a particular operating-system string. Java can execute on different systems, but applications still need portable path handling. Prefer Path and Files for real filesystem operations instead of manually concatenating separators just because this property is available.
public class RuntimeProperties {
public static void main(String[] args) {
String separator = System.getProperty("file.separator");
System.out.println(separator.equals("/") || separator.equals("\\"));
}
}trueJava FAQ
Do I need a separate JRE after installing a JDK?
A normal JDK distribution includes the runtime needed for its tools and applications, so a learner generally does not need another runtime installation. Deployment packaging depends on the vendor and application requirements.
Why does java work but javac fail?
You may have only a runtime, or the JDK compiler's bin directory may be missing from PATH. Check the installed distribution and command locations rather than treating the launcher as proof that every development tool is present.
Is the JVM the same on every operating system?
Each operating system and processor type has its own JVM build, written for that platform. They all run the same bytecode according to the same specification, which is why one compiled .class or .jar file runs on Windows, macOS and Linux.
Do other languages run on the JVM?
Yes. Kotlin, Scala, Groovy and Clojure all compile to JVM bytecode, so they run on the same JVMs and can use Java libraries directly. Kotlin in particular is widely used for Android and server applications alongside Java.
Can I still download a separate JRE?
Oracle stopped offering a separate JRE download with Java 11, and the usual approach now is to install a JDK or package a trimmed runtime with your application using jlink. Some distributions, such as Eclipse Temurin, still publish JRE builds for running applications.
Java Exercises
Answer each one and check it instantly. If you get stuck, open the hint before the answer.
Which tool compiles Java source to class files?
Which component executes bytecode?
Java Quiz
2 questions to check what you learned.
What does Runtime.version describe?
- The runtime executing the program
- The editor version
- Only the source file age
Why use javac --release 17?
- To target Java 17 language, bytecode, and platform APIs
- To install Java 17
- To bypass all errors