Install Oracle Java SE Development Kit 17 in Ubuntu 22.04

Java Standard Edition Development Kit 17 is provided by Oracle Corporation. At the time of writing the article, v17.0.2 is its latest stable release. In this article, we will cover how to install Oracle Java SE Development Kit 17 in Ubuntu 22.04 release.

Since, the package isn’t available through standard Ubuntu repository. Therefore, we need to download the relevant package file (.tar.gz) from the official website of Oracle.

Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Install Oracle Java SE Development Kit in Ubuntu 22.04

Just Google search “Oracle Java” in your browser and it will lead you to its official website. Scroll down the web page, Click on Download Java Button in Java SE section. It takes you to the Downloads page. Therein, look for x64 Compressed Archive.

The package we downloaded was – jdk-17_linux-x64_bin.tar.gz

First, we need to extract the package using tar command-line utility –

tar -xvf jdk-17_linux-x64_bin.tar.gz

It would create jdk-17.0.2/ in current directory.

Use cd command-line utility to navigate inside –

cd jdk-17.0.2/bin/

Thereafter, to check for installed version –

./java --version

It would return with –

java 17.0.2 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

In conclusion, we have discussed how to install Oracle Java SE Development Kit 17 in Ubuntu 22.04 release.

Additional Info –

You would have to provide complete path to jdk-17.0.2/bin/ directory to access Java. Instead, we can set PATH Environment variable.

Edit ~/.bashrc using nano text editor –

nano ~/.bashrc

Append the file with the following –

export PATH=$PATH:/path/to/jdk-17.0.2/bin/

Now, to force changes in current terminal session –

. ~/.bashrc

So, from here onwards – we don’t have to provide the complete PATH to Java. You can check if its working fine –

java --version

See the difference, earlier we used ./java –version instead of java -version.

For more information on PATH environment variable follow the link here