您好,登錄后才能下訂單哦!
Java運用于執行java程序(java運行環境)
Javac運用于java程序編譯(java程序開發環境)
步驟二:alternatives安裝JDK
#alternatives --install /usr/bin/java java /usr/local/jdk版本/bin/java 1
#alternatives --install /usr/bin/javac java /usr/local/jdk版本/bin/javac 2
步驟二:查看可用的版本信息
#alternatives --display java
#alternatives --display javac
步驟三:切換java版本
#alternatives --config java
#alternatives --config javac
刪除jdk版本(可選項,需要刪除時使用--remove)
#alternatives --remove java /usr/local/java/jdk版本/bin
#alternatives --remove javac /usr/local/java/jdk版本/bin
步驟四:修改當前用戶的jdk運行環境
#echo export JAVA_HOME=/usr/bin/java >>~/.bash_profile
# source ~/.bash_profile
注意需要注釋掉/etc/profile文件里面的JAVA_HOM
查看及管理JAVA_HOME
/usr/local/jdk
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
#實例
[cqs@centos7 jdk]$echo ’export JAVA_HOME=/usr/bin/java’ >>~/.bash_profile
[cqs@centos7 jdk]$ echo ‘export PATH=$PATH:$JAVA_HOME/bin’ >>~/.bash_profile
[cqs@centos7 jdk]$ source ~/.bash_profile
注意需要注釋掉/etc/profile文件里面的JAVA_HOM
[cqs@centos7 jdk]$ echo $JAVA_HOME
/usr/bin/java
[cqs@centos7 jdk]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/home/cqs/.local/bin:/home/cqs/bin:/usr/bin/java/bin
步驟一:alternatives安裝JDK1.7(鏈接路徑【link】:/usr/bin/java 鏈接名【name】:java 應用程序JAVA實際路徑【path】:/home/cqs/data/jdk/jdk1.7.0_80/bin/java 優先級【priority】 :1)
[cqs@centos7 jdk]$ sudo alternatives --install /usr/bin/java java ~/data/jdk/jdk1.7.0_80/bin/java 1
[cqs@centos7 jdk]$ sudo alternatives --config java
There is 1 program that provides 'java'.
Selection Command
*+ 1 /home/cqs/data/jdk/jdk1.7.0_80/bin/java
Enter to keep the current selection[+], or type selection number:
[cqs@centos7 jdk]$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
alternatives安裝JDK1.8
[cqs@centos7 jdk]$ sudo alternatives --install /usr/bin/java java ~/data/jdk/jdk1.8.0_161/bin/java 2
[cqs@centos7 jdk]$ sudo alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
1 /home/cqs/data/jdk/jdk1.7.0_80/bin/java
[cqs@centos7 jdk]$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
[cqs@centos7 jdk]$ sudo alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
1 /home/cqs/data/jdk/jdk1.7.0_80/bin/java
*+ 2 /home/cqs/data/jdk/jdk1.8.0_161/bin/java
Enter to keep the current selection[+], or type selection number: 1
[cqs@centos7 jdk]$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。