博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下调整java版本
阅读量:5100 次
发布时间:2019-06-13

本文共 3417 字,大约阅读时间需要 11 分钟。

使用alternatives命令完成,必须具有root权限。

alternative命令介绍

alternatives version 1.3.30.2 - Copyright (C) 2001 Red Hat, Inc.

This may be freely redistributed under the terms of the GNU Public License.
usage: alternatives --install <link> <name> <path> <priority>
                    [--initscript <service>]
                    [--slave <link> <name> <path>]*
       alternatives --remove <name> <path>
       alternatives --auto <name>
       alternatives --config <name>
       alternatives --display <name>
       alternatives --set <name> <path>
看当前java版本:

-bash-3.2$ /usr/sbin/alternatives --display java

java - status is auto.
 link currently points to /usr/lib/jvm/jre-1.6.0-sun/bin/java
/usr/lib/jvm/jre-1.6.0-sun/bin/java - priority 1603
 slave javaws_bin: /usr/lib/jvm/jre-1.6.0-sun/bin/javaws
 slave jcontrol: /usr/lib/jvm/jre-1.6.0-sun/bin/jcontrol
 slave keytool: /usr/lib/jvm/jre-1.6.0-sun/bin/keytool
 slave orbd: /usr/lib/jvm/jre-1.6.0-sun/bin/orbd
 slave pack200: /usr/lib/jvm/jre-1.6.0-sun/bin/pack200
 slave policytool: /usr/lib/jvm/jre-1.6.0-sun/bin/policytool
 slave rmid: /usr/lib/jvm/jre-1.6.0-sun/bin/rmid
 slave rmiregistry: /usr/lib/jvm/jre-1.6.0-sun/bin/rmiregistry
 slave servertool: /usr/lib/jvm/jre-1.6.0-sun/bin/servertool
 slave tnameserv: /usr/lib/jvm/jre-1.6.0-sun/bin/tnameserv
 slave unpack200: /usr/lib/jvm/jre-1.6.0-sun/bin/unpack200
 slave jre_exports: /usr/lib/jvm-exports/jre-1.6.0-sun
 slave jre: /usr/lib/jvm/jre-1.6.0-sun
 slave javaws: /usr/lib/jvm/jre-1.6.0-sun/javaws
 slave java.1: /usr/share/man/man1/java-java-1.6.0-sun-compat.1
 slave javaws.1: /usr/share/man/man1/javaws-java-1.6.0-sun-compat.1
 slave keytool.1: /usr/share/man/man1/keytool-java-1.6.0-sun-compat.1
 slave orbd.1: /usr/share/man/man1/orbd-java-1.6.0-sun-compat.1
 slave pack200.1: /usr/share/man/man1/pack200-java-1.6.0-sun-compat.1
 slave policytool.1: /usr/share/man/man1/policytool-java-1.6.0-sun-compat.1
 slave rmid.1: /usr/share/man/man1/rmid-java-1.6.0-sun-compat.1
 slave rmiregistry.1: /usr/share/man/man1/rmiregistry-java-1.6.0-sun-compat.1
 slave servertool.1: /usr/share/man/man1/servertool-java-1.6.0-sun-compat.1
 slave tnameserv.1: /usr/share/man/man1/tnameserv-java-1.6.0-sun-compat.1
 slave unpack200.1: /usr/share/man/man1/unpack200-java-1.6.0-sun-compat.1
/usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1420
 slave javaws_bin: (null)
 slave jcontrol: (null)
 slave keytool: /usr/lib/jvm/jre-1.4.2-gcj/bin/keytool
 slave orbd: (null)
 slave pack200: (null)
 slave policytool: (null)
 slave rmid: (null)
 slave rmiregistry: /usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistry
 slave servertool: (null)
 slave tnameserv: (null)
 slave unpack200: (null)
 slave jre_exports: /usr/lib/jvm-exports/jre-1.4.2-gcj
 slave jre: /usr/lib/jvm/jre-1.4.2-gcj
 slave javaws: (null)
 slave java.1: (null)
 slave javaws.1: (null)
 slave keytool.1: (null)
 slave orbd.1: (null)
 slave pack200.1: (null)
 slave policytool.1: (null)
 slave rmid.1: (null)
 slave rmiregistry.1: (null)
 slave servertool.1: (null)
 slave tnameserv.1: (null)
 slave unpack200.1: (null)
Current `best' version is /usr/lib/jvm/jre-1.6.0-sun/bin/java.
安装新版本:

-bash-3.2$ /usr/sbin/alternatives --install /usr/bin/java java /home/bio/software/jdk1.6.0_06-x86_64/bin/java 1664

-bash-3.2$ /usr/sbin/alternatives --install /usr/bin/javac javac /home/bio/software/jdk1.6.0_06-x86_64/bin/javac 1664
[root@localhost sbin]# ./alternatives --config java

[root@localhost sbin]# ./alternatives --config javac

分别选择,搞定。

转载于:https://www.cnblogs.com/bluers/archive/2012/10/30/2746624.html

你可能感兴趣的文章
CDH秘籍(两):cloudera Manager存储监控数据
查看>>
linux signal 处理
查看>>
(ZT)算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)
查看>>
LLVM每日谈之二十一 一些关于编译器和LLVM/Clang的代码
查看>>
树形Dp
查看>>
TCP网络编程中RST分节总结
查看>>
Xcode快捷键
查看>>
SVM(三)—Kernels(核函数)
查看>>
基于RPC原理的Dubbo
查看>>
【Spark调优】聚合操作数据倾斜解决方案
查看>>
本周个人总结
查看>>
Ubuntu10.10下ftp的安装配置
查看>>
【转】单调队列初步
查看>>
Grep与web漏洞挖掘<转>
查看>>
树链剖分【p3038】[USACO11DEC]牧草种植Grass Planting
查看>>
.Net中的AOP系列之《单元测试切面》
查看>>
SqlServer根据表中ID加序号
查看>>
python之路_kindEditor编辑器及beautifulsoup模块
查看>>
(zz)最大子序列和问题
查看>>
C# Windows Api的一些方法 封装 以及 常用参数
查看>>