JDK, JRE and JVM Explained Simply for Java Beginners
Almost every Java beginner meets three confusing terms in the first week: JVM, JRE and JDK. They are easy once you see how they fit together.
JVM: the engine that runs Java
The Java Virtual Machine runs compiled Java programs. Because there is a JVM for each operating system, the same compiled program can run on Windows, Linux or macOS. This is the idea behind "write once, run anywhere".
JRE: the runtime
The Java Runtime Environment is the JVM plus the core libraries a program needs in order to run. If you only want to run Java programs, a runtime is enough.
JDK: the developer kit
The Java Development Kit includes the runtime and the tools you need to write programs, such as the javac compiler, the jar tool and a documentation generator. Developers install the JDK.
How a Java program runs
- You write source code in a .java file.
- The javac compiler turns it into bytecode in a .class file.
- The JVM loads the bytecode and runs it on your computer.
javac Hello.java
java HelloWhat should you install?
As a learner, install a JDK. Many modern Java distributions are installed as a JDK, so you usually do not download a separate runtime. Check the documentation for the version you use.
A common beginner error
If the terminal says javac is not recognised, the JDK's bin folder is usually missing from your PATH. Set the PATH, and the JAVA_HOME variable if needed, then open a new terminal window.
Learn Java Programming in Bhubaneswar
Core Java, OOP, collections, exceptions, JDBC and an introduction to web apps. Classroom training at Chakeisiani, with a free demo class.
