How to set up Eclipse in Ubuntu using Sun Java JDK 6

Post Type: 
Tutorial

How to set up Eclipse in Ubuntu using Sun Java JDK 6

This how to is written for Ubuntu however i have used this on process in Debian Etch and Lenny.

Technical ability – medium

This process uses Sun Java JDK 6, make sure it is available in which ever repository you use.

Firstly open a root terminal or use the sudo command and paste the following command into it

sudo apt-get install eclipse sun-java6-jdk

This will install eclipse and the sun-java6-jdk packages (depending on your download speed this could take some time)

This will install your required packages, however eclipse will use the GNU Java by default, and not the Sun version. The GNU version is a lot a slower.

Once those packages have been installed paste the following into your terminal

sudo update-java-alternatives -s java-6-sun

This will update your system to use the Sun Java 6 JDK package

then using your favourite text editor, i tend to use gedit but any editor should do:

sudo gedit /etc/jvm 

and paste the following command into the top of the file

/usr/lib/jvm/java-6-sun

Save the file and exit the text editor

then edit this file, paste the following command into your terminal once again i have used gedit but you can use which ever text editor you like

sudo  gedit /etc/eclipse/java_home

and put the following line into the top of the file 

/usr/lib/jvm/java-6-sun

Save the file and exit the text editor

This should now have set up eclipse using Sun Java JDK 6.

On a personal note it maybe worth playing around with the heap size if you have a lot of memory. However be careful with this as too much will have eclipse starting to act funny. It can be fixed quite easily but remember what you have done to the file.

Edit the Eclipse ini file that can be found in feisty here, if you are not using feisty then all i can suggest is to paste the following into a sudo updatedb and once that is done paste locate eclipse.ini

sudo gedit /usr/lib/eclipse/eclipse.ini

As i have a 1 x gig of RAM i set the heap size to 256Mg like so

VMARGS="-Xms100m -Xmx256m"

Thats it.

Comments

Cheers

Thanks for that,  I didnt realize that eclipse uses the GNU java, or that GNU java existed!

As a side note I got an error of:  Exception in thread "main" java.lang.NoClassDefFoundError: test   when I tried to run the command $>java test   Looking about online I came accross a solution that worked for me.  I used the command $> unset CLASSPATH which seemed to work.   I would also like to add, that setting a CLASSPATH enviroment variable is a bad idea.   Its usually less problematic to let your IDE (im my case Eclipse) do it for you.

Sorted out my problems.

Cheers again.

Huntly

Couple of handy URLS:
*NIX starter guide:  java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html
Troubleshooting: java.sun.com/docs/books/tutorial/getStarted/problems/index.html