在Linode服务器上部署了Debian 7.5,默认使用OpenJDK 1.6。 如何升级到OpenJDK 1.7?
$ java -version
java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1~deb7u1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
跟踪java
,它使用Debian的替代设置:
$ ls -lsa /usr/bin/ | grep java
0 lrwxrwxrwx 1 root root 22 Jul 9 03:50 java -> /etc/alternatives/java
$ ls -lsa /etc/alternatives/java
0 lrwxrwxrwx 1 root root 46 Jul 12 23:02 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
解
在Debian上,您可以使用update-alternatives
配置Java:
注意
了解Debian替代系统
1.安装OpenJDK 1.7
$ sudo apt-get install openjdk-7-jdk openjdk-7-jre
2.更新Java替代路径:
$ 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-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
to provide /usr/bin/java (java) in manual mode
$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1~deb7u1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
做完了
翻译自: https://mkyong.com/linux/debian-change-default-java-version/