This article shows how to install Oracle Java 9 JDK on an Ubuntu Linux system. It should be noted that as of today (April 2018) it is possible to install version 9 of the Oracle JDK only on the 64-bit version of Ubuntu.
Steps
Step 1. Open a "Terminal" window
Access the main menu by pressing the button ⋮⋮⋮, then scroll through the list that appears to locate and select the icon
of the Terminal app
Alternatively, press the key combination Alt + Ctrl + T
Step 2. Uninstall any version of Java currently on the system
This is an extremely important step because not doing so would make the procedure described in this article totally useless. To do this, follow these instructions:
- Type the command sudo apt-get purge openjdk - / *;
- Press the Enter key;
- When prompted, enter the login password of your user account;
- If prompted, press the Y key, then the Enter key.
Step 3. Proceed to install the new version of Java
Type the command sudo apt-get install software-properties-common and press the Enter key.
Step 4. Erase all previous versions of the program
Type the command sudo apt autoremove and press the Enter key. Now wait for the automatic uninstallation procedure to finish. This way you will get two advantages: you will free up free disk space and avoid problems when installing the new version of Java.
The removal process may take several minutes to complete
Step 5. Update the Ubuntu packages
Type the command sudo apt-get update and press the Enter key. This way you can be sure that the version of Java you are going to install is up to date.
Step 6. Log in to Oracle's Java repository
Type the command sudo add-apt-repository ppa: webupd8team / java and press the Enter key.
Step 7. When prompted, press the Enter key again
You will see a message similar to "Press [ENTER] to continue or Ctrl-c to cancel adding it" at the bottom of the "Terminal" window. At this point, press the Enter key again.
Step 8. Download the Java installation file
Type the command sudo apt-get install oracle-java9-installer and press the Enter key, then successively press the Y and Enter keys on your keyboard when prompted. The Java 9 installation file will be downloaded to your computer and a confirmation message will appear in the "Terminal" window when finished.
Step 9. Accept the terms of the license agreement for Java
Press the Enter key once to proceed, use the left directional arrow on your keyboard to select the option Yes then press the Enter key again.
Step 10. Wait for the Java installation procedure to complete
This step should take about 20 minutes, so be patient. When you see your name reappear at the bottom of the "Terminal" window, you can continue.
Step 11. Set Java 9 as the default program
Type the command sudo apt-get install oracle-java9-set-default and press the Enter key, then, if prompted, enter your user account password.
Step 12. Check the version of Java installed on your system
Type the command java -version and press the Enter key. The following text string should appear:
-
java version "9.0.4"
Step 13. Update the Ubuntu packages again
Type the command sudo apt-get update and press the Enter key. It is very likely that, at this point, nothing will happen, but it is still necessary to execute the command indicated to be sure that the Java environment and the rest of the software installed on the system are up to date. At the end of this step, the Java JDK will have been installed on your computer and updated, so you can close the "Terminal" window.