DSA SheetLesson · no judge

PROGRAMMING FUNDAMENTALSJAVA FUNDAMENTALS

JVM, JRE, and JDK: three jobs behind one Java run

Reading · 7 minQuiz · 5 questions2 code drills · run onlyGenerated by gpt-5.6-luna · Aug 25

JVM, JRE, and JDK name three different jobs

For the same Java program, these names describe different responsibilities. The JDK provides the tools used to create and compile Greeting.java. The JRE provides the support a finished program needs while it runs. The JVM is the execution engine that reads Java bytecode and carries out its instructions.

Greeting.java is the source code you start with. Greeting.class is the bytecode produced from that source. The JDK is involved in creating the class file, the JRE supplies the runtime setting, and the JVM executes the class file. Calling all three names interchangeable hides the boundary between building a program and running it.

The role and containment relationship among the JDK, JRE, and JVM for Greeting.javaA large JDK box contains javac and a runtime area. Greeting.java points to javac. Inside the runtime area are the JVM and Java runtime libraries. Greeting.class points to the JVM, showing that the source file belongs to the compilation stage and the class file belongs to the execution stage.Greeting.javajavacGreeting.classJVMJava runtime librariescompileproduces bytecodeexecutesruntime supportJDK development environmentJRE runtime areaJDK = development tools + JRE; JRE = JVM + libraries
The names overlap in what they contain, but not in the job they describe.
CHECKPOINT 1Not answered

Which component must be installed to modify and compile Greeting.java?

Checkpoints are not graded. They are here so you catch yourself before the quiz does — stuck, ask the tutor on the right.

Greeting.java needs a compiler before the JVM can execute it

The journey starts with javac, the compiler provided by the JDK. When you compile Greeting.java, javac translates the source code into Java bytecode and writes that bytecode to Greeting.class. The JVM does not receive the source file at this stage, and it does not create the class file.

TEXTCompilation creates the class file; the java launcher then starts execution.
javac Greeting.java

# javac creates Greeting.class
java Greeting

# the java launcher starts the JVM, which executes Greeting.class
# output:
Hello, Mira

The java launcher is the command that starts the runtime for the class you name. In this case, java Greeting starts a JVM and selects Greeting.class. The JVM reads the bytecode, uses the available runtime support, and the program displays Hello, Mira. Compilation and execution are separate actions, even when you type them one after another.

The complete toolchain path from Greeting.java to its outputA left-to-right path shows Greeting.java entering javac, which produces Greeting.class. The java launcher then starts the JVM with Greeting.class, and the final result is the displayed text "Hello, Mira". There is no direct path from Greeting.java to the JVM.Greeting.javajavacGreeting.classjava launcherJVMProgramoutputHello, Miracompileemit bytecodeselects classstarts JVMexecute
Compilation and execution are separate steps handled by different parts of the toolchain.

The JRE surrounds the JVM with the support a Java program needs

A JVM is the execution engine, but it is not the whole runtime environment. Conceptually, a JRE combines a JVM with Java runtime libraries. Those libraries provide standard capabilities that a running program can use, while the JVM handles the execution of the bytecode. For Greeting.class, the JRE role is the surrounding runtime support, not the creation of the class file.

The JDK is the broader development environment. Conceptually, it adds tools such as javac to the runtime components needed to run Java programs. This is why installing a JDK can support both stages: javac can create Greeting.class, and the included runtime components can start it.

CHECKPOINT 2Not answered

Replace the incorrect component name with the exact tool name: "The JVM compiles Greeting.java into Greeting.class".

The JVM compiles Greeting.java into Greeting.class

Checkpoints are not graded. They are here so you catch yourself before the quiz does — stuck, ask the tutor on the right.

Modern Java installations do not always provide a separately named JRE download. A full JDK commonly includes the runtime components, and a custom runtime can be built with only the pieces an application needs. This changes how the software is packaged, not what the roles mean: development tools build the program, runtime libraries support it, and the JVM executes its bytecode.

A platform-specific JVM lets the same Greeting.class run on different systems

Greeting.class is not tied to one operating system in the same way a native executable usually is. The unchanged file can be copied to Windows 11 and Ubuntu 24.04. On each system, the java launcher starts a JVM implementation built for that operating system, and that JVM reads the same Java bytecode.

Java portability does not mean that one JVM executable runs everywhere. Windows 11 uses a JVM built for Windows, while Ubuntu 24.04 uses a JVM built for Linux. Their platform-specific implementations provide the connection to their operating systems, while the shared bytecode lets both executions represent the same Greeting.class behavior and display Hello, Mira.

OPERATING SYSTEMINPUT TO THE JVMEXECUTION RESULT
Windows 11The unchanged Greeting.classHello, Mira
Ubuntu 24.04The unchanged Greeting.classHello, Mira
The same class file crosses operating systems through different JVM implementations.
Previous · Java vs C++Next part · Quiz