← Back to Chapters

Install JDK & Setup PATH

☕ Install JDK & Setup PATH

? Quick Overview

To run Java programs, you must install the Java Development Kit (JDK) and configure the system PATH. This allows the operating system to recognize Java commands from any location.

? Key Concepts

  • JDK contains tools like javac and java
  • PATH is an environment variable
  • JAVA_HOME points to JDK installation folder
  • Correct setup avoids command not found errors

? Syntax / Theory

After installing the JDK, the system must know where Java is installed. This is done by adding the JDK bin directory to the PATH variable.

? Code Example

? View Code Example
// Check installed Java version
java -version

?️ Live Output / Explanation

If Java is installed correctly, the terminal will display the installed JDK version. If not, it will show an error indicating Java is not recognized.

? Tips & Best Practices

  • Always install the latest LTS version of JDK
  • Restart terminal after setting PATH
  • Verify installation using java -version

? Try It Yourself

  • Install JDK on your system
  • Set JAVA_HOME variable
  • Run javac -version to verify