Now that you've learned what the Java Development Kit (JDK) is, you will need to install it on your system.
Check if Java is Installed
If you are not sure whether or not you have the JDK installed, please open your terminal or command prompt and run the following command:
$ java -version
# or
$ java --version
If you see a response along the lines of command not found: java that means the JDK is not installed on your machine. If you see a response similar to the example below, then you're good to go. You have the JDK already installed on your machine.
openjdk 17.0.5 2022-10-18
OpenJDK Runtime Environment Homebrew (build 17.0.5+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.5+0, mixed mode, sharing)
Which Java Version to Use?
You will be using Java 17 for this course. Any Java version after Java 8 (aka 1.8) should also work. Because Java is so widely used across many industries and has been for decades, there are many versions of Java actively deployed and supported. There are countless production applications running Java 8, Java 11, and Java 17 as of publication. Due to the graph-like nature of Java libraries created by the global Java community it requires many years for the industry as a whole to upgrade from version to version. Here is a quick breakdown:
- Java 8: Still the most widely used version in production. Also, the last version has a cheaper and friendlier corporate licensing agreement.
- Java 11: Second most widely used version in production today. Fewer new applications are being started with Java 11.
- Java 17: Most new applications are being developed using Java 17.
- Java 21: Latest LTS release. It will take a couple of years for the community and the many libraries to be compiled on and have support for Java 21.
Java Release Roadmap
Notice how Java 8, 17, 21, and 25 have "LTS". This indicates "long-term support". Also, notice how each LTS version has "Extended Support Until" 2029 and beyond.
How to Install Java
Installing Java is platform-dependent, so follow the instructions below for your platform.
Install Java on Mac
The easiest way to install Java on your Mac is to use Homebrew. If you do not have Homebrew installed yet, please refer here. With Homebrew, you can install the OpenJDK using the following command:
$ brew install openjdk@17
Install Java on Ubuntu
If you are running Ubuntu, you can run the following commands to install Java.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt install openjdk-17-jdk openjdk-17-jre
Install Java on Windows
If you are running Windows on your machine:
- Download and run the "msi" installer from here.
- Make sure to install the option to "Set JAVA_HOME variable".
Verify JDK Installation
After you have followed the instructions based on your platform and preference above, please verify your installation using the following command:
$ java -version
# or
$ java --version
You should now see an output that indicates your Java version. If you see this, you're good to go.
Summary: How to Install Java JDK
- Check your Java version with
java -versionorjava --version - Java 17 is the recommended Java version to install. Any Java version after Java 8 (aka 1.8) will work.
- There are many active versions of Java being used across the industry.
- Java 8 is still very popular and has the friendliest corporate licensing agreement.