Skip to content

Instantly share code, notes, and snippets.

@bench
Created September 7, 2017 08:51
Show Gist options
  • Save bench/3935f5e72c7dca83a4e31210b2c305e9 to your computer and use it in GitHub Desktop.
Save bench/3935f5e72c7dca83a4e31210b2c305e9 to your computer and use it in GitHub Desktop.
java and javac update-alternatives

update-alternatives maintains symbolic links determining default commands This is a reminder to install java and javac alternatives.

Install alternatives

Install java compiler alternatives

$ sudo update-alternatives --install /usr/bin/javac javac /home/bchenebault/Apps/jdk1.5.0_22/bin/javac 1
$ sudo update-alternatives --install /usr/bin/javac javac /home/bchenebault/Apps/jdk1.6.0_45/bin/javac 2
$ sudo update-alternatives --install /usr/bin/javac javac /home/bchenebault/Apps/jjdk1.7.0_79/bin/javac 3
$ sudo update-alternatives --install /usr/bin/javac javac /home/bchenebault/Apps/jdk1.8.0_101/bin/javac 4

Install java executor alternatives

$ sudo update-alternatives --install /usr/bin/java java /home/bchenebault/Apps/jdk1.5.0_22/bin/java 1
$ sudo update-alternatives --install /usr/bin/java java /home/bchenebault/Apps/jdk1.6.0_45/bin/java 2
$ sudo update-alternatives --install /usr/bin/java java /home/bchenebault/Apps/jjdk1.7.0_79/bin/java 3
$ sudo update-alternatives --install /usr/bin/java java /home/bchenebault/Apps/jdk1.8.0_101/bin/java 4

Modify alternative

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

Display all local alternatives

$ sudo update-alternatives  --get-selections   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment