To begin coding in Java, you need two fundamental tools on your computer: the Java Development Kit (JDK) to compile and run your source code, and a reliable Integrated Development Environment (IDE) or text editor to write your programs.
We recommend installing Eclipse Temurin 21 (Adoptium) or Oracle OpenJDK 21. Follow these instructions for your platform:
If the installer did not configure environment variables automatically, follow these manual steps:
sysdm.cpl, and press Enter to open System Properties.JAVA_HOMEC:Program FilesEclipse Adoptiumjdk-21.0.x-hotspot (the folder path where JDK is installed).Path variable under System variables and click Edit.%JAVA_HOME%in. Click OK on all windows.Open a new Command Prompt (cmd) or PowerShell window and execute the following commands:
# Check Java Runtime version
java -version
# Output should resemble:
# openjdk version "21.0.2" 2024-01-16
# OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13)
# OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13, mixed mode, sharing)
# Check Java Compiler version
javac -version
# Output: javac 21.0.2
Every developer should master manual terminal compilation before using an IDE:
# 1. Create a file named TestApp.java
# 2. Compile source code into bytecode (.class)
javac TestApp.java
# 3. Launch the bytecode on the JVM (omit the .class extension!)
java TestApp
Common Viva Question: "What error happens if you execute java TestApp.class instead of java TestApp?"
Answer: The JVM throws Error: Could not find or load main class TestApp.class. The java command expects the fully-qualified class name, not the physical filesystem filename!
With JDK 21 installed, let us analyze the tripartite relationship between JVM, JRE, and JDK. Proceed to: JVM vs JRE vs JDK Architecture →
Accelerate your Java mastery by studying these tightly connected core tutorials:
Tutorial curriculum.
Internal components breakdown.
Write and compile your first class.
Running classes from terminal.