怎样更改Linux中默认的openjdk为自己安装的JDK

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了怎样更改Linux中默认的openjdk为自己安装的JDK相关的知识,希望对你有一定的参考价值。

系统自带jdk

[root@oldboy ~]# java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-23)

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

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

There are 4 programs which provide ‘java‘.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   2           /usr/java/jdk1.7.0_67-cloudera/bin/java
   3           /usr/java/jdk1.7/bin/java
   4           /usr/local/jdk1.7/bin/java

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

切换后

[root@oldboy ~]# java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

以上是关于怎样更改Linux中默认的openjdk为自己安装的JDK的主要内容,如果未能解决你的问题,请参考以下文章

linux下如何使用自己安装的SunJDK替换默认的OpenJDK

怎样在Linux系统中下载和安装OpenJDK包

phpcms怎样更改默认的站点

如何在默认安装openjdk的Linux系统中安装独立JDK

怎样更改ubuntu linux ibus输入法的快捷键和安装fcitx 五笔代替ibus第一

linux 中 jdk 的安装和卸载