The JVM (Java Virtual Machine) runs compiled Java code, called bytecode; the JRE (Java Runtime Environment) is the JVM plus Java's standard class library, which is everything you need to run a program; and the JDK (Java Development Kit) is a runtime plus the tools for building programs, such as the compiler javac. Each one contains the one before it. This page follows one small program through all three, shows what bytecode looks like, explains where the JRE went after Java 11, and tells you which one to install.
| Name | Stands for | What is inside | What it lets you do |
|---|---|---|---|
JVM | Java Virtual Machine | The engine that loads and runs bytecode, with an interpreter, a JIT compiler and a garbage collector | Run bytecode. You never install it by itself |
JRE | Java Runtime Environment | A JVM plus the standard class library: java.lang, java.util, java.io and the rest | Run programs that are already compiled |
JDK | Java Development Kit | A runtime plus tools such as javac, jar, javadoc, jshell and jlink | Write, compile, package and run programs |
From Hello.java to a running program#
Here is a complete Java program. Press Run and it prints one line.
public class Hello { public static void main(String[] args) { System.out.println("Hello, world."); }}There is no JVM in this page. The Run button uses an interpreter written for this site, which follows Java's rules and runs in your browser, so you can try code before installing anything. On your own computer the same program takes two commands, one for the JDK's compiler and one that starts the JVM:
$ lsHello.java$ javac Hello.java$ lsHello.class Hello.java$ java HelloHello, world.- 1
javac Hello.javaruns the compiler, a JDK tool. It checks the code and writesHello.class, a file of bytecode: instructions for the JVM rather than for your processor. - 2
java Hellostarts a JVM, which loadsHello.classand the library classes it uses, such asSystem, and runs the bytecode. The command takes the class name, with no.classon the end.
Since Java 11 (JEP 330), the java command also accepts the source file itself. It compiles the code in memory, runs it, and leaves no .class file behind:
$ java Hello.javaHello, world.java Hello.class fails with Error: Could not find or load main class Hello.class, because Java reads Hello.class as the name of a class. Use java Hello, or java Hello.java to run straight from the source.Key ideaThe JDK's compiler turns your source code into bytecode once. A JVM, which every Java runtime contains, runs that bytecode each time the program starts.
What bytecode looks like#
A .class file is binary, but the JDK's javap tool prints its bytecode as text. Take a class with one small method:
public class Add { static int add(int a, int b) { return a + b; }}$ javac Add.java$ javap -c Add.classCompiled from "Add.java"public class Add { public Add(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return static int add(int, int); Code: 0: iload_0 1: iload_1 2: iadd 3: ireturn}That is the output of javap; the spacing differs slightly between JDK versions. Read the add method from the top. The JVM works with a stack of values: iload_0 pushes the first argument, a, onto it, iload_1 pushes b, iadd takes both off and pushes their sum, and ireturn hands the sum back. The block above it is the constructor Add(), which javac writes for any class that does not declare one. Nothing in the listing mentions an operating system or a processor.
Why the same .class file runs on Windows, macOS and Linux#
Bytecode is written for the JVM, which the Java Virtual Machine Specification defines as an abstract computing machine: a computer described by rules. Each real JVM is a program built for one operating system and processor, so a JDK for Windows on an Intel chip contains a different JVM from a JDK for a Mac with Apple silicon. All of them run the same bytecode. You compile Hello.java once, and Hello.classruns on any computer with a recent enough Java runtime. Java's old slogan for this is “write once, run anywhere”.
The specification also says that the JVM knows nothing of the Java language, only of the class file format. That is why Kotlin, Scala and Groovy, which compile to class files too, run on the same JVMs.
UnsupportedClassVersionError: Hello“has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 61.0”. Install a newer runtime, or compile for the older one with javac --release 17.What is inside the JVM#
A JVM has three main parts, which is what people mean by JVM architecture:
- The class loader finds the
.classfiles a program needs, loads them into memory and checks that the bytecode is valid before any of it runs. - The runtime data areas are the memory a running program uses: the heap, where objects live; one stack per thread, with a frame for each method call that holds its local variables; and the method area, which holds the code of each class.
- The execution engine runs the bytecode. Its interpreter carries out one instruction at a time, and its garbage collector frees the memory of objects the program no longer uses.
The execution engine also has a JIT compiler(JIT stands for just in time). A JVM starts by interpreting bytecode, and while the program runs it finds the methods that run most often and compiles them into your processor's machine code, so the busiest parts of a program stop being interpreted over and over.
Is the JRE part of the JDK?#
Yes: a JDK contains everything a JRE has, the same JVM and the same standard library, with the development tools added. Up to Java 8 you could see this on disk, because the JDK kept a complete JRE in a folder named jre. Java 9 changed the layout (JEP 220): a JDK is now one runtime with extra tools in its bin folder, and it has no jre folder. That bin folder holds about 30 tools; the ones you meet first are java, javac, jshell, jar and javadoc.
The same nesting answers “does the JRE have a JVM?”. Yes: every Java runtime contains a JVM, because the JVM is the part that runs the program. The library on its own cannot run anything.
Key ideaA JDK is a Java runtime plus tools, and every runtime has a JVM inside. Install a JDK and you have all three.
What happened to the JRE?#
Until Java 11, Oracle offered a JRE download for people who only ran Java programs, next to the JDK for developers. For Java 11 and every version since, Oracle offers only the JDK, and its notes for that release point to jlink instead: a JDK tool, added in Java 9 (JEP 282), that builds a runtime holding only the modules a program needs. This one is made for the Hello program:
$ jlink --add-modules java.base --output my-runtime$ ls my-runtime/binjava keytool$ my-runtime/bin/java HelloHello, world.java.base is the module with Java's core classes, which is all Hello uses. The result has a JVM, that one module and the java command (keytool, a tool for security certificates, belongs to the same module), but no javac: a JRE in all but name, cut to fit one program. A program can ship with a runtime like this, so the people using it never install Java at all. Packaging and shipping a Java app builds one for a real program and turns it into an installer with jpackage.
Some vendors still publish a ready-made JRE for each version. Eclipse Temurin, for one, offers JRE downloads of Java 25 next to its JDK downloads.
Which one do you need?#
- To learn Java or write programs, install a JDK, because only a JDK has
javac. Any build of Java 25 is fine, and your first Java program walks through installing one. - To run a program someone gives you, use whatever runtime it comes with. If it is a plain
.jarfile, you need a Java runtime of the version it was built for or later. A JRE is enough, and a JDK works just as well. - To play Minecraft: Java Edition, you need neither. The game includes its own Java: the notes for version 26.1 say it requires Java 25 and ships the Microsoft Build of OpenJDK 25.
- To host a Minecraft server, you install Java yourself, because the server is a
.jarfile you start with thejavacommand. Minecraft's server page asks for a compatible JRE, and a JDK of the same version works too.
How to check whether you have a JDK#
Run two commands in a terminal. java -version answers when any Java runtime is installed, and javac -versionanswers only when you have a JDK. With Eclipse Temurin's first Java 25 release they print:
$ java -versionopenjdk version "25" 2025-09-16 LTSOpenJDK Runtime Environment Temurin-25+36 (build 25+36-LTS)OpenJDK 64-Bit Server VM Temurin-25+36 (build 25+36-LTS, mixed mode, sharing)$ javac -versionjavac 25The three lines from java -version name the layers: the version, the runtime environment, and the JVM itself, here the 64-Bit Server VM.
java -version answers but javac -versiongets a message such as “command not found” or “is not recognized”, the computer has a Java runtime and no JDK. Install a JDK, then open a new terminal so it finds the new commands.OpenJDK, Oracle JDK and other builds#
OpenJDK is the open-source project where Java itself is written, led by Oracle together with other companies and volunteers. A JDK you download is a build of its code:
- Oracle JDK, Oracle's own build under Oracle's license. Oracle also publishes plain OpenJDK builds under the GPL at jdk.java.net.
- Eclipse Temurin, from the Adoptium project, free, with JDK and JRE downloads.
- Amazon Corretto, Amazon's free build.
- The Microsoft Build of OpenJDK, the one Minecraft ships.
All of them start from the same OpenJDK source code, so they run your programs the same way. They differ in who builds them, how long each version gets updates, and the license terms. For learning, any of them at version 25 does the job.
Questions people ask#
- What is the difference between JDK, JRE and JVM?
- The JVM runs compiled Java bytecode, the JRE is the JVM plus Java's standard class library (everything needed to run a program), and the JDK is a runtime plus the tools for building programs, such as the compiler
javac. Each one contains the one before it, so a JDK can both compile and run Java programs. - Does the JRE have a JVM?
- Yes. Every JRE contains a JVM, because the JVM is the part that runs the program, and the JRE adds the standard library the program calls. A JDK contains a JVM as well.
- Is the JRE part of the JDK?
- Yes: a JDK contains everything a JRE has, so it runs programs as well as building them. Up to Java 8 the JDK even kept a complete JRE in a folder named
jre; since Java 9 it is a single runtime with the development tools added. - What is the full form of JDK?
- JDK stands for Java Development Kit. JRE stands for Java Runtime Environment, and JVM for Java Virtual Machine.
- Do I need the JDK or the JRE?
- Install a JDK to learn Java or write programs, because only a JDK has the compiler
javac. To run a finished program you only need a Java runtime, and many programs, Minecraft: Java Edition among them, include their own. - Can I still download a JRE for Java 11 or later?
- Not from Oracle, which has offered only the JDK since Java 11. Some other builds, such as Eclipse Temurin, still publish a JRE for each version, and any JDK can build a small runtime for one program with
jlink.
Further reading#
- Introduction to the Java Virtual Machine Specification, Java SE 25 edition
- JEP 330: Launch Single-File Source-Code Programs (java Hello.java, Java 11)
- JEP 282: jlink, the Java Linker that builds custom runtimes (Java 9)
- Significant changes in JDK 11, from the JDK 25 migration guide (the end of Oracle's JRE downloads)