Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script update all Java related alternatives to point a manually installed JDK.
#!/bin/bash
# Run update-alternatives for a manual installed JDK
JAVA_HOME=/opt/java/jdk1.8.0_152
java_bins=(appletviewer extcheck idlj jarsigner java javac javadoc javafxpackager javah javap javapackager java-rmi.cgi javaws jcmd jconsole jcontrol jdb jdeps jhat jinfo jjs jmap jps jrunscript jsadebugd jstat jstatd jvisualvm keytool native2ascii orbd pack200 policytool rmic rmid schemagen servertool tnameserv wsgen wsimport xjc jar jmc jmc.ini jstack rmiregistry serialver unpack200)
for java_bin in ${java_bins[@]}; do
echo "Setting $java_bin..."
update-alternatives --install /usr/bin/$java_bin $java_bin $JAVA_HOME/bin/$java_bin 1
update-alternatives --set $java_bin $JAVA_HOME/bin/$java_bin
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.