DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Specify Default JDK on Ubuntu


sudo update-alternatives --config java produced:

     Selection Path           Priority Status
------------------------------------------------------------
 0   /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071  auto mode
*1   /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java 1061  manual mode
 2   /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071  manual mode

The you can select a number to specify the default JDK.

Use sudo update-alternatives --config javac config the javac version.

How about you have installed a jdk with rpm, but it doesn't appear in the list?

Now I download Oracle JDK6 installer, jdk-6u45-linux-x64-rpm.bin, run this file, it automatically install jdk-6u45-linux-amd64.rpm, which is extracted from the previous installer. But when the result of java -version is still openjdk. So I need to find where the package installed, and set its path into JAVA_HOME.

# rpm -qa | grep jdk
java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64
jdk-1.6.0_45-fcs.x86_64
java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
# rpm -ql java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
// from the file list we know the java path is: /usr/java/jdk1.6.0_45/bin
# /usr/java/jdk1.6.0_45/bin/java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
# echo "export JAVA_HOME=/usr/java/jdk1.6.0_45" >> /etc/profile
# source /etc/profile


Published

Jun 26, 2013

Last Updated

Jun 26, 2013

Category

Tech

Tags

  • Java 106
  • switch 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor