Last active
October 6, 2021 18:24
-
-
Save sansmoraxz/343809913ff6fcc8e4bf28f0887f68fd to your computer and use it in GitHub Desktop.
Use Oracle JDK in Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#user inputs java path | |
if [[ $1 ]] | |
then | |
JAVA_PATH="$1/bin" | |
# use JAVA_HOME environment variable | |
elif [[ $JAVA_HOME ]] | |
then | |
JAVA_PATH="$JAVA_HOME/bin" | |
else | |
echo "I can't even guess where your jdk really is. Please tell me. :(" | |
exit 1 | |
fi | |
#JAVA_PATH="/usr/lib/jvm/jdk-15.0.2/bin" | |
FILES="$(ls $JAVA_PATH)" | |
for path in $JAVA_PATH/*; do | |
file="$(basename $path)" | |
# Priority 2000 | |
# Also enables experimental or decryted features | |
sudo update-alternatives --install "/usr/bin/$file" $file $path 2000 | |
done |
#!/bin/sh
JAVA_PATH=/usr/lib/jvm/jdk-15.0.2/
sudo update-alternatives --install /usr/bin/java java $JAVA_PATH/bin/java 10 \
--slave /usr/bin/jaotc jaotc $JAVA_PATH/bin/jaotc\
--slave /usr/bin/jar jar $JAVA_PATH/bin/jar\
--slave /usr/bin/jarsigner jarsigner $JAVA_PATH/bin/jarsigner\
--slave /usr/bin/javac javac $JAVA_PATH/bin/javac\
--slave /usr/bin/javadoc javadoc $JAVA_PATH/bin/javadoc\
--slave /usr/bin/javap javap $JAVA_PATH/bin/javap\
--slave /usr/bin/jcmd jcmd $JAVA_PATH/bin/jcmd\
--slave /usr/bin/jconsole jconsole $JAVA_PATH/bin/jconsole\
--slave /usr/bin/jdb jdb $JAVA_PATH/bin/jdb\
--slave /usr/bin/jdeprscan jdeprscan $JAVA_PATH/bin/jdeprscan\
--slave /usr/bin/jdeps jdeps $JAVA_PATH/bin/jdeps\
--slave /usr/bin/jfr jfr $JAVA_PATH/bin/jfr\
--slave /usr/bin/jhsdb jhsdb $JAVA_PATH/bin/jhsdb\
--slave /usr/bin/jimage jimage $JAVA_PATH/bin/jimage\
--slave /usr/bin/jinfo jinfo $JAVA_PATH/bin/jinfo\
--slave /usr/bin/jlink jlink $JAVA_PATH/bin/jlink\
--slave /usr/bin/jmap jmap $JAVA_PATH/bin/jmap\
--slave /usr/bin/jmod jmod $JAVA_PATH/bin/jmod\
--slave /usr/bin/jpackage jpackage $JAVA_PATH/bin/jpackage\
--slave /usr/bin/jps jps $JAVA_PATH/bin/jps\
--slave /usr/bin/jrunscript jrunscript $JAVA_PATH/bin/jrunscript\
--slave /usr/bin/jshell jshell $JAVA_PATH/bin/jshell\
--slave /usr/bin/jstack jstack $JAVA_PATH/bin/jstack\
--slave /usr/bin/jstat jstat $JAVA_PATH/bin/jstat\
--slave /usr/bin/jstatd jstatd $JAVA_PATH/bin/jstatd\
--slave /usr/bin/keytool keytool $JAVA_PATH/bin/keytool\
--slave /usr/bin/rmid rmid $JAVA_PATH/bin/rmid\
--slave /usr/bin/rmiregistry rmiregistry $JAVA_PATH/bin/rmiregistry\
--slave /usr/bin/serialver serialver $JAVA_PATH/bin/serialver\
--slave /usr/share/man/man1/jabswitch.1 jabswitch.1 $JAVA_PATH/man/man1/jabswitch.1\
--slave /usr/share/man/man1/jaccessinspector.1 jaccessinspector.1 $JAVA_PATH/man/man1/jaccessinspector.1\
--slave /usr/share/man/man1/jaccesswalker.1 jaccesswalker.1 $JAVA_PATH/man/man1/jaccesswalker.1\
--slave /usr/share/man/man1/jaotc.1 jaotc.1 $JAVA_PATH/man/man1/jaotc.1\
--slave /usr/share/man/man1/jar.1 jar.1 $JAVA_PATH/man/man1/jar.1\
--slave /usr/share/man/man1/jarsigner.1 jarsigner.1 $JAVA_PATH/man/man1/jarsigner.1\
--slave /usr/share/man/man1/java.1 java.1 $JAVA_PATH/man/man1/java.1\
--slave /usr/share/man/man1/javac.1 javac.1 $JAVA_PATH/man/man1/javac.1\
--slave /usr/share/man/man1/javadoc.1 javadoc.1 $JAVA_PATH/man/man1/javadoc.1\
--slave /usr/share/man/man1/javap.1 javap.1 $JAVA_PATH/man/man1/javap.1\
--slave /usr/share/man/man1/jcmd.1 jcmd.1 $JAVA_PATH/man/man1/jcmd.1\
--slave /usr/share/man/man1/jconsole.1 jconsole.1 $JAVA_PATH/man/man1/jconsole.1\
--slave /usr/share/man/man1/jdb.1 jdb.1 $JAVA_PATH/man/man1/jdb.1\
--slave /usr/share/man/man1/jdeprscan.1 jdeprscan.1 $JAVA_PATH/man/man1/jdeprscan.1\
--slave /usr/share/man/man1/jdeps.1 jdeps.1 $JAVA_PATH/man/man1/jdeps.1\
--slave /usr/share/man/man1/jfr.1 jfr.1 $JAVA_PATH/man/man1/jfr.1\
--slave /usr/share/man/man1/jhsdb.1 jhsdb.1 $JAVA_PATH/man/man1/jhsdb.1\
--slave /usr/share/man/man1/jinfo.1 jinfo.1 $JAVA_PATH/man/man1/jinfo.1\
--slave /usr/share/man/man1/jlink.1 jlink.1 $JAVA_PATH/man/man1/jlink.1\
--slave /usr/share/man/man1/jmap.1 jmap.1 $JAVA_PATH/man/man1/jmap.1\
--slave /usr/share/man/man1/jmod.1 jmod.1 $JAVA_PATH/man/man1/jmod.1\
--slave /usr/share/man/man1/jpackage.1 jpackage.1 $JAVA_PATH/man/man1/jpackage.1\
--slave /usr/share/man/man1/jps.1 jps.1 $JAVA_PATH/man/man1/jps.1\
--slave /usr/share/man/man1/jrunscript.1 jrunscript.1 $JAVA_PATH/man/man1/jrunscript.1\
--slave /usr/share/man/man1/jshell.1 jshell.1 $JAVA_PATH/man/man1/jshell.1\
--slave /usr/share/man/man1/jstack.1 jstack.1 $JAVA_PATH/man/man1/jstack.1\
--slave /usr/share/man/man1/jstat.1 jstat.1 $JAVA_PATH/man/man1/jstat.1\
--slave /usr/share/man/man1/jstatd.1 jstatd.1 $JAVA_PATH/man/man1/jstatd.1\
--slave /usr/share/man/man1/keytool.1 keytool.1 $JAVA_PATH/man/man1/keytool.1\
--slave /usr/share/man/man1/kinit.1 kinit.1 $JAVA_PATH/man/man1/kinit.1\
--slave /usr/share/man/man1/klist.1 klist.1 $JAVA_PATH/man/man1/klist.1\
--slave /usr/share/man/man1/ktab.1 ktab.1 $JAVA_PATH/man/man1/ktab.1\
--slave /usr/share/man/man1/rmid.1 rmid.1 $JAVA_PATH/man/man1/rmid.1\
--slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 $JAVA_PATH/man/man1/rmiregistry.1\
--slave /usr/share/man/man1/serialver.1 serialver.1 $JAVA_PATH/man/man1/serialver.1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you don't know where it was installed likely places candidates are
/usr/lib/jvm/
or/opt/java