Java 1.5 and Eclipse in Gentoo – Part II
My previous post discussed the installation of Java on a Gentoo system. Its all well as long as you want to run the default supported version of java on the Gentoo system – you install blackdown-jdk 1.4, Eclipse 3.0, and maybe Eclipse CDT too and get on with development. But if you want to install java 1.5(Tiger) then you need to unmask the package before you can install it and also remember to make blackdown(or sun) jdk 1.4 as the default JVM for the system. You can keep sun jdk 1.5 as the default JVM for the user. The procedure is like this:
[sun-jdk-1.5.0.06] “Sun JDK 1.5.0.06″ (/etc/env.d/java/20sun-jdk-1.5.0.06) *
[blackdown-jdk-1.4.2.03] “Blackdown JDK 1.4.2.03″ (/etc/env.d/java/20blackdown-jdk-1.4.2.03)
This shows you all the installed jdks on your system. Use the name as given under the brackets to set that particular jvm as your system default:
sh# /usr/sbin/env-update && source /etc/profile
This sets the blackdown jdk 1.4 as the system jvm, which is the recommended option. You can set the sun jdk 5.0 as the user default jvm though:
sh# echo source ~/.gentoo/java-env >> ~./bash_profile
sh# source ~/.gentoo/java-env
This sets the sun jdk 1.5 as the user jvm and it is safe this way. But don’t make 1.5 version as the default jvm for the system unless you are ready to break a lot of java applications.
Best way to install Java on Gentoo OS:
But this still is not an ideal setup from my point of view; the installed Eclipse version doesn’t support the Java 1.5 version. If you want to use the latest versions of all the java software without going through all of these hassles, you need to install everything related to java manaully in the user home directory. This won’t affect your normal portage structure in any way(but you still need a system jdk to run java applications from the browser).
First download the latest versions of Java SDK and the Eclipse IDE from the Internet and copy them into the home directory.
Download sun jdk 1.5.0 update 6 from here and copy it into the home directory. You will have to accept the license to be able to download this. Be sure to download the .bin version of the file and not the RPM version.
Download the latest version of the Eclipse IDE from here and copy it in the home directory. The latest build available currently is Eclipse 3.2M5a. If you plan to use Eclipse CDT plugin to create C++ applications, then you have to be content with the Eclipse 3.1.2 version.
(All the above links are for the gnu/linux, 32-bit operating system. Finding similar package files for 64-bit systems shouldn’t be too difficult)
Install jdk as a normal user:
sh# ./jdk_1_5_0_06-linux-i586.bin
sh# tar xvzf eclipse-sdk-3,1,2-linux-gtk.tar.gz
Rename the directory to which the above files are extracted to something simple, like “eclipse”.
Now add the following lines to your user profile( eg ~/.bash_profile ):
JDK_HOME=~/jdk1.5.0_06
JAVAC=~/jdk1.5.0_06/bin/javac
PATH=~/jdk1.5.0_06/bin:~/jdk1.5.0_06/jre/bin:~/eclipse:$PATH
MANPATH=$MANPATH:~/~/jdk1.5.0_06/man
JAVA_HOME=~/jdk1.5.0_06
source the profile once and start the Eclipse IDE:
sh# eclipse
Go to Windows menu and select Preferences from it. Select Java -> Installed JREs from the left pane and click on the “Add” button on the right pane.

Browse to and select jdk1.5.0_06/jre directory from your home directory. Enter “JDK1.5.0_06″ in “JRE Name:” field. Click on Java -> Compiler item from the left pane and select “5.0″ from the “Compiler Compliance Settings:” selection list.

Click OK button to dismiss the dialog box.
Now you can create java 1.5 applications on your Gentoo system using the Eclipse IDE.
Just extract the Eclipse CDT tar file in the eclipse folder to get the C++ support in Eclipse. (contents of ‘features’ directory from downloaded package should go into the ‘features’ directory in eclipse, and contents of ‘plugins’ directory should go into the ‘plugins’ directory in eclipse).
[...] More information on installing java 1.5 and eclipse 3.x on Gentoo OS. Filed under: GNU/Linux, Gentoo, Java — tabrez @ 3:36 pm | [Digg this] [del.icio.us] [...]
QuotePingback by Every Flavour Beans » Java on Gentoo — May 10, 2006 @ 5:50 pm
Thanks for posting this useful piece of advise. I am just about to install Gentoo on a laptop and use it primarily for Eclipse development. Your site is bookmarked.
QuoteComment by Sri Raguraman — December 9, 2006 @ 12:18 am
Glad to hear that! I am always on the lookout for the people who are using Gentoo, my favourite operating system :)
QuoteComment by tabrez — December 10, 2006 @ 3:06 pm
Thanx for this post – much helpful. Minor typo error above – should be ~/.bash_profile
QuoteComment by Paul Hewlett — December 18, 2008 @ 8:22 pm