Created
June 13, 2020 18:59
-
-
Save JoseAlavez/fa548bc4bd4a9c30f60d1bbe77174431 to your computer and use it in GitHub Desktop.
pick_jdk
This file contains 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 | |
PATH_SOURCE=~/.bash_profile | |
JDK8_HOME=/opt/java/jdk/jdk8u252-b09 | |
JDK11_HOME=/opt/java/jdk/jdk-11 | |
function installJDK(){ | |
sudo update-alternatives --install "/usr/bin/java" "java" "$1/bin/java" 1 | |
sudo update-alternatives --install "/usr/bin/javac" "javac" "$1/bin/javac" 1 | |
sudo update-alternatives --install "/usr/bin/jar" "jar" "$1/bin/jar" 1 | |
sudo update-alternatives --install "/usr/bin/javadoc" "javadoc" "$1/bin/javadoc" 1 | |
} | |
function setJDK(){ | |
sudo update-alternatives --set java $1/bin/java | |
sudo update-alternatives --set javac $1/bin/javac | |
sudo update-alternatives --set jar $1/bin/jar | |
sudo update-alternatives --set javadoc $1/bin/javadoc | |
sed -ir "s|JAVA_HOME=.*|JAVA_HOME=$1|g" $PATH_SOURCE | |
} | |
function setJDK8(){ | |
setJDK $JDK8_HOME | |
} | |
function setJDK11(){ | |
setJDK $JDK11_HOME | |
} | |
function installJDK8(){ | |
installJDK $JDK8_HOME | |
setJDK8 | |
} | |
function installJDK11(){ | |
installJDK $JDK11_HOME | |
setJDK11 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment