Thursday, April 09, 2009

Ubuntu - Changing default Java version

I recently installed Frostwire, but somehow I couldn't able to even start Frostwire. In command line it used show following error log:

An unexpected error has been detected by Java Runtime Environment:

However, other Java applications such as Vuze were working perfectly.

Later I found that, If have a 64 bit machine and have installed both 32 bit and 64 bit version of Java, then you can have only one among them active at a time.

ie; You can use either Vuze or Frostwire, as Vuze requires 64 bit Java, whereas Frostwire needs 32 bit verison of Java.

By default last installed version of Java will be used as the default Java. This can be changed by issuing following command:

$sudo update-alternatives --config java

When you issue this command you will see something like this:
There are 4 alternatives which provide `java'.

Selection Alternative
1 /usr/bin/gij-4.2
* 2 /usr/lib/jvm/java-6-sun/jre/bin/java
3 /usr/lib/jvm/ia32-java-6-sun/jre/bin/java
+ 4 /usr/lib/jvm/java-7-icedtea/jre/bin/java

Press enter to keep the default[*], or type selection number:

In this list, entry number 2 corresponds to the 64 bit Java and entry number 3 corresponds to the 32 bit Java version. The star (*) present over the second entry, means that 64 bit version of Java is in use presently.

Whenever you want 32 bit Java, issue above mentioned command and press 3 to select 32 bit Java. Similarly, Whenever you want 64 bit Java, issue above mentioned command and press 2 to select 64 bit Java.

Same command can be used to select SUN Java package instead of GNU Compiler for the Java or GCJ.

Hope this helps you people..

No comments: