标签:style openjdk deb jre_home lte alter linu jvm nbsp
流程簡述一下
sudo apt-get install default-jdk
很可惜,這個會安裝新的jdk,目前是jdk11
java --version
安裝jdk8
sudo apt-get install openjdk-8-jdk
安裝version後還是jdk11
安裝在 /usr/lib/jvm/
default-java其實指到jdk11
ll /usr/bin/ | grep java
其實指指到alternatives
ll /etc/alternatives/ | grep java
其實指到 jdk11
看一下可用的java,8只有jre
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/bin/java
要設定 ,路徑未註冊
sudo update-alternatives --config java
看一下目前的設定
ctrl+c
開始註冊,註冊的語法為 update-alternatives: --install needs <link> <name> <path> <priority>
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/bin/java 1110
config
java -version 看個版本
cd /etc/profile.d
sudo vim java_path.sh
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ export JRE_HOME=${JAVA_HOME}/jre/ export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
填入存檔,然後手動執行一次上面指令,以在當前環境生效
ref
https://docs.datastax.com/en/jdk-install/doc/jdk-install/installOpenJdkDeb.html
https://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk
https://blog.gtwang.org/linux/how-to-install-java-with-apt-get-on-ubuntu-linux/
标签:style openjdk deb jre_home lte alter linu jvm nbsp
原文地址:https://www.cnblogs.com/seako/p/13193725.html