Download and Install JDK

To develop Java programs we require the JDK (Java Development Kit). The JDK contains the development tools such as the compiler and runtime environment that are used for compiling, debugging and executing Java programs.

When the JDK is installed, it will also come with Development Tools and JRE (Java Runtime Environment). The JRE in turn will contain the Java Class Library and the JVM (Java Virtual Machine):

Image illustrating how the JDK is structured, JRE contains the JVM, and the JDK contains the JRE.
Diagram illustrating how JDK is structured, with JVM inside JRE and JRE inside JDK.

Once a Java program has been compiled, it can then be executed. To execute a Java program, we require the JVM, which is a part of the JRE.

Say we have a program file 'First.java', we use a compiler to compile the program, the Java compiler javac comes as part of the JDK. Once the program has been compiled, we will get a file called 'First.class'. Use the command java First to execute the program, this will use the JRE which internally it uses the JVM. javac compiler is a development tool that comes as part of the JDK and java is the Java launcher, which will start the runtime environment.