Guide to Offline Installation of JDK 17 on Ubuntu
This tutorial is based on Ubuntu 20.04.
JDK Installation
-
Go to Oracle website and download the JDK version that matches your operating system architecture. Ubuntu users can choose either Debian Package or Compressed Archive. In this example, we choose the Compressed Archive.
-
Drag and drop the downloaded file
jdk-17.0.7_linux-x64_bin.tar.gz
to the target directory, such as/root
. -
Navigate to the target directory
/root
and run the following command to extract the file:tar -xf jdk-17.0.7_linux-x64_bin.tar.gz
-
The above command extracts jdk-17.0.7_linux-x64_bin.tar.gz into a directory named jdk-17.0.7. You can rename this directory to a more suitable name. For example, if you want to rename it to jdk-17, you can use the following command:
mv jdk-17.0.7 jdk-17
-
You can move the JDK directory to the desired installation location. For instance, you can use the following command to move it to the
/usr/lib/jvm/
directory:sudo mv jdk-17 /usr/lib/jvm/
-
Set the environment variables to use the newly installed JDK. Open the
/etc/environment
file in a text editor. You can use nano or vim command. -
Add the following code to the file, under PATH, for the JAVA_HOME environment variable. Replace it with the actual directory name if you didn’t rename it to
jdk-17
in step 4:JAVA_HOME="/usr/lib/jvm"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:$JAVA_HOME/bin"
-
Save the file and exit the text editor.
-
Apply the changes to the environment by executing the following command:
source /etc/environment
-
Verify if the JDK has been installed and configured correctly by running the following command:
java -version
If the JDK has been installed correctly, this command should display the installed Java version and other relevant information.
By following these steps, you should be able to deploy the Linux x64 JDK compressed version (jdk-17.0.7_linux-x64_bin.tar.gz) on your Ubuntu 20.04 machine.