Module 1: Getting Started
Install the JDK
Install a JDK and verify your Java development tools.
To compile and run Java programs, install a Java Development Kit (JDK). A JDK includes the Java compiler, runtime tools, and utilities used during development.
1. Choose a JDK distribution#
Use a supported JDK distribution from a trusted vendor, such as Oracle JDK or an OpenJDK distribution. Choose a version that matches your course, project, or employer's requirements. For learning, a current long-term-support (LTS) release is a sensible default.
2. Install it#
Download the installer for your operating system from the chosen distribution's official website and follow its installation instructions. On Windows, note the installation directory if the installer asks you to choose one.
3. Verify the installation#
Open a new terminal or Command Prompt and run:
java -version
javac -version
The first command displays the runtime version. The second checks that the compiler is installed and available on your command path. Both commands should report a version rather than an error such as “command not found” or “not recognized”.
If the command is not found#
- Confirm the JDK installation completed successfully.
- Open a new terminal so updated environment variables are loaded.
- Check that the JDK's
bindirectory is included inPATH. - On systems that use
JAVA_HOME, make sure it points to the JDK directory, not directly to itsbindirectory. - Run the version commands again.
Avoid copying environment-variable values from a different computer; installation paths vary.
Quick check#
java -version and javac -version test related but different commands. A working java command alone does not always mean the compiler is available, so verify both before continuing.