ubuntu – 安装openjdk-7-jdk不会更新java(仍然是版本1.6)

我在更新Java时遇到问题.我正在运行Ubuntu 11.10.

我可以执行sudo apt-get install openjdk-7-jdk并成功完成. javac -version是1.7,但是java -version是1.6.这类似于this problem,但据我所知,我的问题并非如此.

$echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

谢谢.

解决方法:

更新:

找到一个有很好解释的网站:LINK

从链接:

然后我们必须做一些配置.
Debian有一个脚本来维护不同版本的程序,比如java,称为update-alternatives.

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 1065
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 1065

1065是给定优先级的地方.

要检查我的安装,请使用-config参数
update-alternatives –config java
这打印:
替代java有两种选择(提供/usr/bin/java).

Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk1.7.0/bin/java             1065      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/jdk1.7.0/bin/java             1065      manual mode

  

并且因为1065高于1061,所以在我的机器上默认使用全新安装的java 7
java -version
打印:

java version "1.7.0"
 Java(TM) SE Runtime Environment (build 1.7.0-b147)
 Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

注意:这可能使其更容易理解.

SLES11 # which java
/usr/bin/java

SLES11 # update-alternatives --list java
/usr/lib64/jvm/jre-1.6.0-ibm/bin/java

SLES11 # update-alternatives --display java
java - status is auto.
 link currently points to /usr/lib64/jvm/jre-1.6.0-ibm/bin/java
/usr/lib64/jvm/jre-1.6.0-ibm/bin/java - priority 1608
 slave rmiregistry: /usr/lib64/jvm/jre-1.6.0-ibm/bin/rmiregistry
 slave tnameserv: /usr/lib64/jvm/jre-1.6.0-ibm/bin/tnameserv
 slave rmid: /usr/lib64/jvm/jre-1.6.0-ibm/bin/rmid
 slave jre_exports: /usr/lib64/jvm-exports/jre-1.6.0-ibm
 slave policytool: /usr/lib64/jvm/jre-1.6.0-ibm/bin/policytool
 slave keytool: /usr/lib64/jvm/jre-1.6.0-ibm/bin/keytool
 slave jre: /usr/lib64/jvm/jre-1.6.0-ibm
Current `best' version is /usr/lib64/jvm/jre-1.6.0-ibm/bin/java.

手册页提供了update-alternatives用于其目录的路径.

SLES11 # pwd
/etc/alternatives

SLES11 # ll
lrwxrwxrwx 1 root root 37 Mar 19 06:03 java -> /usr/lib64/jvm/jre-1.6.0-ibm/bin/java
lrwxrwxrwx 1 root root 28 Mar 19 06:03 jre -> /usr/lib64/jvm/jre-1.6.0-ibm
lrwxrwxrwx 1 root root 28 Mar 19 06:03 jre_1.6.0 -> /usr/lib64/jvm/jre-1.6.0-ibm
lrwxrwxrwx 1 root root 36 Mar 19 06:03 jre_1.6.0_exports -> /usr/lib64/jvm-exports/jre-1.6.0-ibm
lrwxrwxrwx 1 root root 36 Mar 19 06:03 jre_exports -> /usr/lib64/jvm-exports/jre-1.6.0-ibm
lrwxrwxrwx 1 root root 28 Mar 19 06:03 jre_ibm -> /usr/lib64/jvm/jre-1.6.0-ibm
lrwxrwxrwx 1 root root 36 Mar 19 06:03 jre_ibm_exports -> /usr/lib64/jvm-exports/jre-1.6.0-ibm

如果您已安装它们并且只需要更改默认值,则进行更改.

SLES11 # update-alternatives --config java

There is only 1 program which provides java
(/usr/lib64/jvm/jre-1.6.0-ibm/bin/java). Nothing to configure.

原答案:

如果查看/ etc / java或/ etc / java-7-openjdk之类的内容,您应该看到配置文件.
java.conf或jvm.cfg

这通常(取决于)配置文件设置您的选项.您可以同时安装多个版本的Java,并更改启动变量以影响哪个是您的默认JVM.

来自CentOS java.conf

# If you have the a base JRE package installed
# (e.g. java-1.6.0-openjdk):
#JAVA_HOME=$JVM_ROOT/jre

# If you have the a devel JDK package installed
# (e.g. java-1.6.0-openjdk-devel):
#JAVA_HOME=$JVM_ROOT/java 

来自Ubuntu jvm.cfg

# List of JVMs that can be used as an option to java, javac, etc.
# Order is important -- first in this list is the default JVM.
# NOTE that this both this file and its format are UNSUPPORTED and
# WILL GO AWAY in a future release.
#
# You may also select a JVM in an arbitrary location with the
# "-XXaltjvm=" option, but that too is unsupported
# and may not be available in a future release.
#
-server KNOWN
-client IGNORE
-hotspot ERROR
-classic WARN
-native ERROR
-green ERROR
-jamvm KNOWN
-cacao KNOWN
-zero KNOWN
-shark ALIASED_TO -zero

在Ubuntu上有一个名为update-java-alternatives的程序
这是手册页的前几行

NAME
       update-java-alternatives - update alternatives for jre/sdk installations

SYNOPSIS
       update-java-alternatives [--jre] [--plugin] [-t|--test|-v|--verbose]
             -l|--list []
             -s|--set 
             -a|--auto
             -h|-?|--help

DESCRIPTION
       update-java-alternatives  updates  all  alternatives belonging to one runtime or development kit for the Java language.  A package does provide these
       information of it's alternatives in /usr/lib/jvm/..jinfo.
root@ubuntul:/# update-java-alternatives -l  
java-1.6.0-openjdk 1061 /usr/lib/jvm/java-1.6.0-openjdk
 -s|--set 
              Set all alternatives of the registered jre/sdk installation to the program path provided by the  installation.

对于java启动环境,我通常也会看到/etc/profile.d中的链接.

我的猜测是你的java库安装在同一个地方,配置文件仍然默认为原始版本.您应该只需要提供新的JVM路径.

上一篇:python实战因子分析factor analysis


下一篇:python实战因子分析factor analysis