Skip to content

Instantly share code, notes, and snippets.

@jeffcogswell
Last active August 2, 2020 16:33
Show Gist options
  • Save jeffcogswell/8c47fb21355faf346a7336998ce76e07 to your computer and use it in GitHub Desktop.
Save jeffcogswell/8c47fb21355faf346a7336998ce76e07 to your computer and use it in GitHub Desktop.
Update Alternatives for Java

There are a lot of Q&As out there on how to do this... Some good info here: http://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk

I usually install my JDK under /usr/lib/jvm alongside the others:

cd /usr/lib/jvm
sudo tar xf ~/Downloads/jdk-8u91-linux-x64.tar.gz
sudo chown -R root:root jdk1.8.0_91
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_91/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_91/bin/javac 1
sudo update-alternatives --install /usr/bin/jexec jexec /usr/lib/jvm/jdk1.8.0_91/lib/jexec 1
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jexec

NOTE: If you're also installing netbeans and hit some problems with the JDK not being found, you can configure it in the netbeans installation directory in etc/netbeans.conf. Search for the jdkhome and point it accordingly, e.g.:

netbeans_jdkhome="/usr/lib/jvm/jdk1.8.0_91"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment