Install the JDKπ± Beginner
Before you can write and run Java code, you need to install the JDK (Java Development Kit). This gives you the compiler (javac), the execution engine (JVM), and all essential developer tools.
What to Install
There are many distributions of Java, but the safest and most popular choice for modern development is a free, open-source LTS (Long-Term Support) build like Eclipse Temurin (available at adoptium.net). Aim for Java 21 or Java 25.
Why Configure the PATH?
After installing the JDK, your operating system needs to know where the Java commands live. By setting the JAVA_HOME environment variable and adding it to your system PATH, tools like Maven or Gradle can automatically find your JDK, and you can run java from any terminal window.
How to Verify the Installation
Open your terminal and run these commands to ensure both the runtime and compiler are correctly mapped:
java -version # Verifies the JVM runtime
javac -version # Verifies the Java compiler
If you see the version numbers, you are good to go! If you get a "command not found" error, you need to configure your PATH.
# macOS / Linux (add this to your ~/.zshrc or ~/.bashrc)
export JAVA_HOME=/path/to/your/jdk
export PATH="$JAVA_HOME/bin:$PATH"JAVA_HOME pointing to the JDK folder, and append %JAVA_HOME%\bin to the Path variable. Restart your terminal afterward.Choosing an IDE
While you can write Java in a basic text editor, an IDE (Integrated Development Environment) will drastically speed up your workflow by offering autocomplete, instant error checking, and integrated debugging.
- IntelliJ IDEA: The absolute industry standard for Java (the Community edition is 100% free).
- VS Code: A great lightweight alternative if you install the "Extension Pack for Java".