如何用新安裝的jdk替換掉Linux系統預設jdk

梓沐發表於2016-07-21

系統自帶的JDK

[root@master ~]# java -version

java version "1.5.0"

gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-3)

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.

自己配置的jdk

[hadoop@master ~]$ echo $JAVA_HOME

/usr/java/jdk1.8.0_60

但是系統預設的用的是系統自帶的jdk,下面切換到安裝的jdk版本

[root@master ~]# alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_60/bin/java 300

[root@master ~]# 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/java/jdk1.8.0_60/bin/java

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

系統自帶的jdk時,是帶gij的,輸入java命令如下:

[root@master ~]# java -version

java version "1.5.0"

gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-3)

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.

自己安裝的jdk,輸入java命令如下:

[root@master ~]# java -version

java version "1.8.0_60"

Java(TM) SE Runtime Environment (build 1.8.0_60-b27)

Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29812844/viewspace-2122312/,如需轉載,請註明出處,否則將追究法律責任。

相關文章