make Sun's java the default in ubuntu
October 7th, 2007
Okay, so you installed all required packages to get Sun's JRE and/or JDK in your Ubuntu box, but when you try to run a java program you don't get Sun's jvm.
To see what jvm is your current default, run this command:
In this example we see that we are currently using gcj.
To change the default jvm, run this command:
You will be presented a menu with all the available jvms, and you will be prompted to choose your new default:
To check if the new default is set correctly run the previous command again:
To see what jvm is your current default, run this command:
~$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 34 2007-10-06 07:40
/etc/alternatives/java → /usr/lib/jvm/java-gcj/jre/bin/javaIn this example we see that we are currently using gcj.
To change the default jvm, run this command:
$ sudo update-alternatives --config javaYou will be presented a menu with all the available jvms, and you will be prompted to choose your new default:
$ sudo update-alternatives --config java
Password: *******
There are 3 alternatives which provide `java'.
Selection Alternative
--------------------------------------------------------------------------------------------
1 /usr/lib/jvm/java-6-sun/jre/bin/java
2 /usr/bin/gij-wrapper-4.1
*+ 3 /usr/lib/jvm/java-gcj/jre/bin/java
Press enter to keep the default[*], or type selection number: 1
Using `/usr/lib/jvm/java-6-sun/jre/bin/java' to provide `java'.To check if the new default is set correctly run the previous command again:
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 36 2007-10-07 12:21
/etc/alternatives/java → /usr/lib/jvm/java-6-sun/jre/bin/java