我有t1.micro 64位实例,我按照一些指令(sudo yum install java-1.7.0-openjdk-devel
)(sudo yum update
等)安装了JDK 7。所以,当我搜索它时,
sudo yum search openjdk
我得到了关注 -
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
所以,两者都已安装。但是当我尝试使用
切换到JDK 7时sudo update-alternatives --config java
我明白了 -
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
为什么只显示6?
我尝试了其他命令,如 -
sudo update-alternatives --set javac /usr/lib/jvm/java-7-openjdk/bin/javac
但没有成功。
答案 0 :(得分:13)
要确保安装了openjdk 7,请运行以下命令。
# rpm -qa | grep openjdk
如果已安装,则应列出1.6和1.7。如果它只列出1.6(就像我猜的那样),那么sudo update-alternatives --config java
工作正常,您需要通过运行yum -y install java-1.7.0-openjdk
来安装jdk 7
这是我机器的输出:
# rpm -qa | grep openjdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1.x86_64
java-1.6.0-openjdk-1.6.0.0-65.1.11.14.57.amzn1.x86_64
# update-alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
2 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
Enter to keep the current selection[+], or type selection number: