Saturday, May 5, 2012

Making Oracle JAVA work on Ubuntu 12.04

With the suspension of support for more Ubuntu friendly format from Oracle we sometime face issues with installing Oracle Jdk 7 on ubuntu.
I have a 64 bit oracle JDK installed on my system from the following PPA
you need to perform the following steps for installing the oracle JDK7 on your ubuntu 12.04 64 bit system
1. $> sudo add-apt-repository ppa:webupd8team/java
2. $> sudo apt-get update
3. $> sudo apt-get install oracle-java7-installer
After this you can check and select which java version you would like to use on the system
$>sudo update-alternatives --config java
Once this is done you probably would like to ensure that browser is using this java plugin, for that you need to carry out these options
create a "plugins" directory in the "~/.mozilla" path
$> mkdir ~/.mozilla/plugins 
Now you need to have a soft link to the actual file, which will be responsible for running the java on your browser(mozilla/chrome/chromium all use this plugins directory)   
$>ln -s /usr/lib/jvm/java-7-oracle/jre/lib/amd64/ ~/.mozilla/plugins
Once this is done you check the oracle link Test Page to see if the java is running fine on your system  
Now you would probably like to run eclipse on your system, for that these is a catch. I was facing issues when i was trying to open eclipse form my system and was getting this error
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
no swt-gtk-3740 in java.library.path
no swt-gtk in java.library.path
What this means is that the .swt folder at your home directory is missing few files which you need to manually copy. First you need to have following packages installed(generally they are installed if you have Gnome 3) 
$> sudo apt-get install libswt-gtk-3-jni libswt-gtk-3-java
Once you have installed these packages you can proceed to copy files which are needed
$> sudo cp /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64
In case its a i386 install then the command will be 
$> sudo cp /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86
You could also create the soft link to required files -> /usr/lib/jni/ -> /usr/lib/jni/ -> /usr/lib/jni/ -> /usr/lib/jni/ -> /usr/lib/jni/ -> /usr/lib/jni/ -> /usr/lib/jni/ -> /usr/lib/jni/
Once this is done you need to edit the eclipse.ini file to explicitly tell eclipse which VM to use. If you have installed eclipse using the Ubuntu Software Center you need to go to the following path to edit the file
$> sudo gedit /usr/lib/eclipse/eclipse.ini
You can specify the VM by adding these lines in the file

Once all these steps are done you should be ready with starting your development in Java on Ubuntu  12.04 64bit.

Enjoy !

References :   :    :    :

No comments: