In this article we will quickly install Oracle Java JDK 10 on Ubuntu 17.10 machine from terminal. There are multiple methods of doing it, some more easy and some more sophisticated, like using bash scripts. It always depends on use case, but we will do it as simple as it can be. For this moment Java 10 and Ubuntu 17.10 are fresh versions so you may find it useful like I did.
Sometimes scripts available on the Internet wont’t work, as I encountered this issue. For example installing Java using PPA like this:
sudo add-apt-repository ppa:linuxuprising/java sudo apt-get update sudo apt-get install oracle-java10-installer
Which in my case ended like this:
[...] 2018-05-22 19:00:23 ERROR 404: Not Found. download failed Oracle JDK 10 is NOT installed. [..]
This is because link for Java 10 resource files was broken, maybe Oracle change something.
Instead of trying fixing it I installed it manually by adding few commands more and have more flexibility of installing Java 10.
In regular browser copy link of download resource and paste it inside wget command
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz
Unpack downloaded tar.gz to desired location:
sudo tar zxf jdk-10.0.1_linux-x64_bin.tar.gz -C /usr/local
Then we use update-alternatives to setup java 10 as our default java:
sudo update-alternatives --install /usr/bin/java java /usr/local/jdk-10.0.1/bin/java 2 sudo update-alternatives --set javac /usr/local/jdk-10.0.1/bin/javac sudo update-alternatives --config java
The configuration tool – you just choose 0,1,2,3 option which version you want to be default:
Then you check java version using command:
And that’s how you install Oracle Java JDK. You can use this method to install any version of Java on your Ubuntu 17.10 machine.
Hope you find it useful.
If you want, leave a comment below or contact me directly Contact Page 😉