javac 在 fedora 23 上显示不同版本

javac 在 fedora 23 上显示不同版本

我在 Oracle VM 中安装了来自 fedora 23 终端的以下命令

[root@localhost local]# java -version
openjdk version "1.8.0_60"
OpenJDK Runtime Environment (build 1.8.0_60-b27)
OpenJDK 64-Bit Server VM (build 25.60-b23, mixed mode)
[root@localhost local]# su
[root@localhost local]# update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-14.b27.fc23.x86_64/jre/bin/java
   2           /usr/java/jdk1.8.0_77/jre/bin/java

Enter to keep the current selection[+], or type selection number: 2
[root@localhost local]# java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
[root@localhost local]# javac -version
javac 1.8.0_60
[root@localhost local]# 

我看到不同的版本javacjava显示我安装的版本。我该如何解决?我尝试运行which javawhich javac,结果分别是/usr/local/java/usr/local/javac

答案1

java程序和javac替代方案是相互独立控制的。看看您设置了什么替代方案javac

# update-alternatives --config javac

There are 2 programs which provide 'javac'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/java-1.6.0-openjdk.x86_64/bin/javac
*+ 2           /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javac

# update-alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/lib/jvm/jre-1.5.0-gcj/bin/java

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

相关内容