Debian : Change default Java version
By:Roy.LiuLast updated:2019-08-17
Deployed a Debian 7.5 on Linode server, the default is using OpenJDK 1.6. How to upgrade to 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)
Tracing the java, it’s using the Debian’s alternative settings :
$ 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
Solution
On Debian, you can use update-alternatives to configure Java :
Note
Understand the Debian alternatives system
Understand the Debian alternatives system
1. Install OpenJDK 1.7
$ sudo apt-get install openjdk-7-jdk openjdk-7-jre
2. Update Java alternative path :
$ 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)
Done.
From:一号门
Previous:Download file from server using SSH
Next:log4j.xml Example
COMMENTS