JDK vs JRE vs JVM and How Java Runs
JDK, JRE and JVM is the opening question of most Java interviews. The JDK is the toolkit to build Java programs, the JRE was the runtime to run them, and the JVM is the virtual machine that loads bytecode and runs it with a JIT compiler.
What you will learn
- Explain JDK, JRE and JVM and how they relate
- Follow a program from .java to .class to running code
- Explain "write once, run anywhere"
- Know the current LTS releases
Key concepts
JVM
The Java Virtual Machine loads .class files, verifies the bytecode, interprets it and compiles hot methods to native code with the JIT compiler. It also manages memory and garbage collection. There is a JVM build per OS and CPU.
JRE
The JVM plus the core class libraries needed to run programs. Since Java 11 there is no separate JRE download; you ship a JDK or build a trimmed runtime with jlink.
JDK
The JRE plus development tools: javac (compiler), java, jar, javadoc, jshell, jcmd, jlink.
LTS releases
Long-term support versions: 8, 11, 17, 21 and 25 (September 2025). Most companies run 17 or 21 and are moving to 25.
Step by step
From source to running code
- javac compiles Hello.java to platform-independent bytecode in Hello.class
- java Hello starts a JVM; the class loader loads the class
- The bytecode verifier checks it is safe
- The interpreter runs it; hot methods are compiled to machine code by the JIT (C1, then C2)
Examples
Compile and inspect bytecode
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, JioCoder");
}
}
// javac Hello.java → Hello.class
// java Hello → runs it
// javap -c Hello → shows the bytecode
// java Hello.java → single-file source launch (Java 11+)Practise it
Try these without looking back. If you can explain each one out loud, you are ready for this question.
- Explain why the same .class file runs on Windows and Linux.
- Explain why Java is called both compiled and interpreted.
Interview questions
What interviewers ask next on this topic. Answer out loud first, then open the model answer.
Is Java platform independent? Is the JVM?
Java bytecode is platform independent. The JVM is not: each OS and CPU needs its own JVM build, which is what makes the same bytecode run everywhere.
Why is main public static void?
public so the JVM can call it from outside the class, static so it can be called without creating an object, void because the program reports exit status through System.exit, and String[] args receives command-line arguments. Java 25 also allows simpler instance main methods for small programs.
Summary
javac turns source into bytecode, the JVM loads, verifies, interprets and JIT-compiles it, the JDK holds the tools, and LTS versions 17, 21 and 25 are what production runs.
Stuck on this one? Talk to Sumit.
Keys: F focus mode · ← → previous / next topic · Esc leave focus