How Java Runs
Java separates source code from the instructions executed by the JVM. The javac compiler checks source and produces .class files containing bytecode.
At runtime, the JVM loads classes, verifies bytecode, and executes it. Frequently run code may be compiled further by the just-in-time compiler.
The normal cycle
Main.java
|
| javac Main.java
v
Main.class (JVM bytecode)
|
| java Main
v
Java Virtual Machine
|
v
program output
Source code is for people and the compiler. Bytecode is a portable instruction format for JVM implementations. It is not the machine code of one particular processor.
The command names also differ:
| Command | Role |
|---|---|
javac Main.java | Compile source into bytecode |
java Main | Launch the class named Main |
The launcher receives a class name, not Main.class. It locates the bytecode through the class path and calls the entry-point method.
Since Java 11, the launcher can also run a single source file directly with java Main.java. The traditional two-step model remains important because larger builds compile many classes before launching an application.
This course's runner follows that cycle: it compiles Main.java and then launches the resulting Main class on Java 25.
The names around a Java installation are easy to mix up:
| Name | What it provides |
|---|---|
| JVM | Runs Java bytecode |
| JRE | JVM plus libraries needed to run applications |
| JDK | JRE plus development tools such as javac |
Put the compiler and JVM in their correct roles in the question below.