安装/升级 jdk 时终端中的这些输出是什么

安装/升级 jdk 时终端中的这些输出是什么

我一直在安装 jdk

我有多个问题

1.在第一行,当我尝试设置 java 的替代方案时,它说 java 已经被管理,这是什么意思

2.为什么我必须输入 java1、javac1。我不能输入 java2、javac2 吗?

3.当我尝试设置备用 java 时,它说我有 3 种不同的优先级状态,其中前两个是相同的,并且自动模式和手动模式之间存在差异。

4.最后一行我选择java2,会有什么不同吗?我可以自由选择任意数字吗?

neeraj@dodo:/$ sudo update-alternatives --install /usr/bin/java javac /usr/lib/jvm/jdk1.8.0_72/bin/javac 1
[sudo] password for neeraj: 
update-alternatives: error: alternative link /usr/bin/java is already managed by java
neeraj@dodo:/$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_72/bin/java 1
neeraj@dodo:/$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.8.0_72/bin/javaws 1
update-alternatives: using /usr/lib/jvm/jdk1.8.0_72/bin/javaws to provide /usr/bin/javaws (javaws) in auto mode
neeraj@dodo:/$ sudo update-alternatives --config javac
update-alternatives: error: no alternatives for javac
neeraj@dodo:/$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java)

Selection Path Priority Status

* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/jdk1.8.0_72/bin/java                1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.8.0_72/bin/java to provide /usr/bin/java (java) in manual mode
neeraj@dodo:/$ sudo update-alternatives --config javaws
There is only one alternative in link group javaws (providing /usr/bin/javaws): /usr/lib/jvm/jdk1.8.0_72/bin/javaws
Nothing to configure.
neeraj@dodo:/$ java -version
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
neeraj@dodo:/$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_72/bin/java 1
[sudo] password for neeraj: 
neeraj@dodo:/$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_72/bin/java 2

答案1

我关注关联用于安装 Oracle/Sun JDK,它对我来说工作正常。

在一个实例中,我需要手动更新 /etc/environment 中的 JAVA_HOME(通过编辑它)

JAVA_HOME=/path-to-java-before bin directory
export $JAVA_HOME
source /etc/environment

希望这能有效。

相关内容