linux下的alternative的多版本管理
centos是自带的openjdk,安装eclipse时, 下载最新的jdk。解压到/usr/java目录下。
tar zxvf jre-8u121-linux-x64.tar.gz
设置环境变量
#vi /etc/profile
export JAVA_HOME="/usr/java/jdk1.8.0_121"
export CLASS_PATH=".:/usr/java/jdk1.8.0_121/lib/dt.jar:/usr/java/jdk1.8.0_121/lib/tools.jar"
export PATH="$PATH:/usr/java/jdk1.8.0_121/bin"
#source /etc/profile
2 | [[email protected] ~] # alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_21/bin/java 400 |
3 | [[email protected] ~] # alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_21/bin/javac 400 |
现在可以看看注册的成果了:
01 | [[email protected] ~] # alternatives --config java |
02 | |
03 | There are 3 programs which provide 'java' . |
04 | |
05 | Selection Command |
06 | ----------------------------------------------- |
07 | *+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java |
08 | 2 /usr/java/jre1.6.0_21/bin/java |
09 | 3 /usr/java/jdk1.6.0_21/bin/java |
10 | |
11 | Enter to keep the current selection[+], or type selection number: |
这里输入想要用的 java 就可以了,例如我选在了第2个。我们看看 /usr/bin/java的变化:
1 | [[email protected] ~] # ll /usr/bin/java |
2 | lrwxrwxrwx 1 root root 22 Dec 17 2009 /usr/bin/java -> /etc/alternatives/java |
3 | [[email protected] ~] # ll /etc/alternatives/java |
4 | lrwxrwxrwx 1 root root 30 Aug 23 15:03 /etc/alternatives/java -> /usr/java/jre |
相关推荐
yaodilu 2020-05-10
pigsmall 2020-11-19
SXIAOYI 2020-09-16
Ladyseven 2020-07-25
whileinsist 2020-06-24
gufudhn 2020-06-12
冰蝶 2020-06-05
LinuxAndroidAI 2020-06-04
supperme 2020-05-28
e度空间 2020-04-27
云端漂移 2020-04-09
peterwzc 2020-03-17
有心就有方向 2012-09-03
ebuild 2013-05-14
donghedonghe 2013-05-31
tdeclipse 2011-02-28
linuxprobe0 2013-04-15
linuxprobe0 2013-04-01