Introduction to Java | Programming Basics

JDK, JVM, and JRE in Java

When you start programming in Java, you'll often encounter terms like JDK, JVM, and JRE. These are essential components of the Java programming environment. Understanding the differences between them will help you as you set up your development environment and run Java programs.

What is JDK?

The JDK (Java Development Kit) is a software development kit used to develop Java applications. It includes:

The JDK is the complete package for developing Java programs. If you're developing Java applications, you'll need to install the JDK.

What is JVM?

The JVM (Java Virtual Machine) is a virtual machine that runs Java bytecode. It is platform-independent, meaning Java applications can run on any machine that has the JVM installed, regardless of the underlying hardware and operating system.

What is JRE?

The JRE (Java Runtime Environment) is a package that includes everything required to run Java applications, except for the development tools like the compiler. It consists of:

Differences Between JDK, JVM, and JRE

Component Purpose Includes
JDK Used for Java development (coding, compiling, and debugging) JVM, JRE, development tools (e.g., javac)
JVM Executes Java bytecode Part of both JDK and JRE
JRE Provides the environment to run Java applications JVM, Java libraries, and other supporting files

Code Example: JDK, JVM, and JRE in Action

Here’s a simple example of a Java program that runs on the JVM. To develop and run this program, you'll need the JDK to compile it and the JVM to run it.

Code Example


                public class HelloJava {
                    public static void main(String[] args) {
                        System.out.println("Hello, Java World!");
                    }
                }
                    

Output

Hello, Java World!

Pro Tip:

💡 Pro Tip

Whenever you're working with Java, you’ll need the JDK for development. If you're just running Java applications, the JRE will suffice. The JVM is a fundamental part of both, enabling Java’s cross-platform capabilities.