Last Updated on 15/11/2020
This tutorial will show how to install Java 9 on Ubuntu and validate the setup to make sure the necessary environment variables for development are set.
In Ubuntu terminal, add the repository where Java 9 installation packages can be found. It’s the same repository where you can find the Java 8 installation packages:
sudo add-apt-repository ppa:webupd8team/java
Update the packages list with the newly added repository and install the Java 9:
sudo apt-get update sudo apt-get install oracle-java9-installer
Note that the download may take a while since the Java 9 installer is considerably bigger than the previous versions.
Additionally, during the installation process, you must confirm the Java 9 download and accept the licence agreement. After the confirmations, wait until the installation process is complete.
Environment Variables and Validation
The installation through the above steps often automatically performs the necessary changes on the environment for Java development on Ubuntu, so unlike Windows, you shouldn’t need to manually set up any environment variables.
So, let’s validate the installation with the following commands:
java -version java version "9" Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
javac -version javac 9
I hope it helps.