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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.