Get started Bring yourself up to speed with our introductory content.

5 steps for an easy JDK 13 install on Ubuntu

The on-time release of Java 13 -- along with its new language features and JVM enhancements -- made waves at Oracle Code One 2019 in San Francisco in September.

But of course, you can't take advantage of any of these new features if JDK 13 isn't installed. Let's explore how to install JDK 13 on Ubuntu, and demonstrate how to set JAVA_HOME and the PATH environment variables on your Linux distribution.

Step 1: Download and extract the JDK binaries

You can obtain the AdoptOpenJDK distribution of Java 13 through the Java website. Then, download the 64-bit Linux distribution.

download JDK 13
Official JDK 13 download location.

Once the download is complete, it saves a gzip file named openjdk-13_linux-x64_bin.tar.gz into your downloads folder. Extract the contents of this file in the same folder.

Step 2: Move the JDK binaries to /opt/

In the first subfolder of the extracted JDK 13 binaries, there will be a folder named JDK-13. Use the terminal window to move this folder into Ubuntu's /opt directory

jdk13@ubuntu:$ sudo mv jdk-13 /opt/

Step 3: Set JAVA_HOME and PATH in your Ubuntu profile

After you move the binaries to /opt/, the next step is to set the JAVA_HOME and PATH for the JDK 13 install. These variables must be set every time Ubuntu starts. I'd recommend you run a tee command and add them to a script that runs every time a user logs in.

jdk13@ubuntu:$ sudo tee /etc/profile.d/jdk13env.sh <<EOF
export JAVA_HOME=/opt/jdk-13
export PATH=\$PATH\$JAVA_HOME/bin
EOF

set JAVA_HOME and PATH
Set JAVA_HOME and PATH in the user profile and in the Ubuntu terminal.

When you run tee command, it will create the file with the JAVA_HOME and PATH variable settings, but it won't run the file. To get these variables to take effect, run the file using the source command:

jdk13@ubuntu: $ source /etc/profile.d/jdk13env.sh

Step 4: Echo the newly set JAVA_HOME and PATH variables

Next, validate that you successfully executed the step to set JAVA_HOME and PATH with the echo command.

jdk13@ubuntu:$ echo $JAVA_HOME
/opt/jdk-13

jdk13@ubuntu:$ echo $PATH
/usr/local/sbin:usr/local/bin:/opt/jdk-13/bin

Step 5: Verify the JDK 13 on Ubuntu installation

With the JDK-13 folder moved to /opt and the step to set JAVA_HOME and the PATH completed, you can validate the JDK 13 install when you run the java –version command. The result should appear as follows:

jdk13@ubuntu:$ java –version
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (mixed mode, sharing)

Steps to install JDK 13 on Ubuntu and set JAVA_HOME

In summary, the five steps to install JDK 13 on Ubuntu and set JAVA_HOME and the PATH variables are:

  1. Download and extract the JDK binaries.
  2. Move the JDK binaries to /opt.
  3. Set JAVA_HOME and PATH locally and in your Ubuntu profile.
  4. Echo the newly set JAVA_HOME and PATH
  5. Run java –version to validate the JDK 13 on Ubuntu installation.

That's all there is to install JDK 13 on an Ubuntu machine and set the JAVA_HOME and PATH variables properly.

View All Videos

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

What new Java 13 features are you most excited about incorporating into your daily programming routines?
Cancel

-ADS BY GOOGLE

SearchSoftwareQuality

SearchHRSoftware

SearchSAP

SearchERP

Close