Saturday, October 15, 2016

How to Change Default JDK with AlternativesI

Here is how to set Oracle's JDK as your default. You can apply this to set OpenJDK as default as well very easily.

First, you will need to download Oracle's JDK. Visit here to download the latest JDK for your system.

For Debian-based Linux, you simply need to download the tar.gz archive and extract to a folder. For example,
$ tar xvfz jdk-8u101-linux-x64.tar.gz
$ sudo mv jdk1.8.0_101 /opt/

Next, set Oracle's JDK as an alternative:
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_101/bin/java 100
$ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_101/bin/javac 100

Finally, set whichever version you would prefer:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

That's it!

No comments:

Post a Comment