Navigate your browser to the official Oracle java download page and download the latest binaries.
We are interested in eg.
Download java file and save it into your home directory:
$ ls ~/jdk-10.0.1_linux-x64_bin.tar.gz /home/linuxconfig/jdk-10.0.1_linux-x64_bin.tar.gz
Now, that your java download is completed and you have obtained the Oracle JDK binaries, execute the following linux commands to perform the java ubuntu install into a
$ sudo mkdir /opt/java-jdk $ sudo tar -C /opt/java-jdk -zxf ~/jdk-10.0.1_linux-x64_bin.tar.gz
The following linux commands will set Oracle JDK as system wide default. Amend the below commands to suit your installed version:
$ sudo update-alternatives --install /usr/bin/java java /opt/java-jdk/jdk-10.0.1/bin/java 1 $ sudo update-alternatives --install /usr/bin/javac javac /opt/java-jdk/jdk-10.0.1/bin/javac 1
What remains is to check for installed java version:
$ java --version java 10.0.1 2018-04-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode) $ javac --version javac 10.0.1
All you have to do now is to set the “JAVA_HOME” and “PATH” environment variables and then you are done. Enter the following commands to set your environment variables. Make sure that your environment variables point to a valid installation of JDK on your machine. For Ubuntu 18.04, the path is /usr/lib/jvm/java-8-openjdk-amd64/
To check whether your JAVA_HOME path has been successfully saved, enter the following command to check.
The value stored in the JAVA_HOME variable will be displayed on the terminal as you can see in the screenshot