Java升级替换java version "1.5.0"

首先进行java安装

http://www.cnblogs.com/someone9/p/8670585.html

2. 然后查看版本信息,仍然是1.5.0

[root@OKC java]# java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-18)

Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 3.然后执行

[root@OKC ~]# alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_161/bin/ 300
appletviewer    javac           javaws          jinfo           jsadebugd       orbd            serialver
ControlPanel    javadoc         jcmd            jjs             jstack          pack200         servertool
extcheck        javafxpackager  jconsole        jmap            jstat           policytool      tnameserv
idlj            javah           jcontrol        jmc             jstatd          rmic            unpack200
jar             javap           jdb             jmc.ini         jvisualvm       rmid            wsgen
jarsigner       javapackager    jdeps           jps             keytool         rmiregistry     wsimport
java            java-rmi.cgi    jhat            jrunscript      native2ascii    schemagen       xjc

 4.进行选择配置 填写 3 .我们刚配置的环境

[root@OKC ~]# alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 2           /usr/bin/java/jdk1.8.0_161/bin/java
   3           /usr/java/jdk1.8.0_161/bin/java

Enter to keep the current selection[+], or type selection number: 3

 5.再次查看版本信息

[root@OKC ~]# 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)

 注:

假若第三步所配置的不是我们安装的位置,或者超出目录范围将会报错

-bash: /usr/bin/java: Too many levels of symbolic links
按照上面第三步重新配置即可
[root@OKC java]# alternatives --install /usr/bin/java java /usr/bin/java/jdk1.8.0_161/bin/java 300
[root@OKC java]# java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-18)

Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@OKC java]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   2           /usr/bin/java/jdk1.8.0_161/bin/java

Enter to keep the current selection[+], or type selection number: 2
[root@OKC java]# java -version
-bash: /usr/bin/java: Too many levels of symbolic links

 

转载于:https://www.cnblogs.com/someone9/p/8991895.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值