This is a summary of the steps I did to install Oracle Java8 on my laptop running Ubuntu 16.10 (Yakkety Yak). I used the PPA repositories provided by Wepupd8 and specifically referred to this very detailed post.
Please note that most Linux distros recommend openjdk as the default Java platform. However, there are some products that specifically recommend Oracle’s JDK for their products. I had one such product to install for my work and had to install Oracle’s JDK.
So here we go. Here are the main steps with the commands further below…
- Add webupd8’s PPA repositories for oracle java.
- Install Oracle Java.
- Set Oracle Java as the default.
- Verify that Oracle java is set as the default JVM.
Add webupd8’s PPA repositories for oracle java.
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update
Install Oracle Java. Do note that you will have to accept the binary license during the install, so stay there.
$ sudo apt-get install -y oracle-java8-installer
Set Oracle Java as the default.
$ sudo apt-get install -y oracle-java8-set-default
Verify that Oracle java is set as the default JVM.
$ java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) Server VM (build 25.111-b14, mixed mode)
If you see the HotSpot server VM being output then you are good. Finally, cleanup the unneeded stuff
$ sudo apt autoremove
Additionally, you may want to set the
JAVA_HOME environment variable. Some products need this environment variable. To do this, enter the following line as the last line in
~/.bashrc file. Of course, this assumes you are using BASH as your shell. If you use some other shell, like fish or zsh, then check appropriately how to set
$ file `which java` /usr/bin/java: symbolic link to /etc/alternatives/java $ file /etc/alternatives/java /etc/alternatives/java: symbolic link to /usr/lib/jvm/java-8-oracle/jre/bin/java $ echo "export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre" >> ~/.bashrc
So that’s that. You should be all set now.