How to install Java and check the version

Choose a JDK

Install a current long-term-support JDK from Eclipse Temurin, Oracle, or your operating system package manager. A JDK includes the tools needed to compile and run Java.

Check the runtime

Open a new terminal after installation and ask the Java runtime for its version.

java --version

Check the compiler

The compiler should report the same major version as the runtime.

javac --version

Fix command problems

  • Reopen the terminal so it receives updated environment variables.
  • Set JAVA_HOME to the JDK directory when a tool requires it.
  • Add the JDK's bin directory to PATH if commands are not found.