The simplest way to get started with Java development in Gentoo is to install the Blackdown JDK-1.4.2 along with the Eclipse IDE:

sh# emerge blackdown-jdk eclipse-sdk

If you want to install the sun’s version of the jdk instead of the blackdown jdk, you can get the 1.4.2 version of it using:

sh# emerge sun-jdk java-sdk-docs

To install the 1.5 version of the jdk, you need to unmask it first. Add the following two lines to your /etc/portage/package.keywords file:

>=dev-java/sun-jdk-1.5.0 ~x86
>=dev-java/java-sdk-docs-1.5.0 ~x86

Now do the emerge:

sh# emerge sun-jdk java-sdk-docs

You can also install both of these versions at the same time, and then make one of them as the default jdk. If you need java support in other applications too(like web browser etc), then make sure to add the relevant keywords in the /etc/portage/package.use file:

=dev-java/sun-jdk-1.4.2.10-r2 X alsa browserplugin doc examples jce mozilla nsplugin

This also installs the documentation and the examples – remove these words if you don’t to install them. Also change the version number if you are installing the 1.5 version of the jdk.

If you want to use Eclipse IDE to create C++ programs, you need the eclipse-cdt plugin. First unmask it by placing the following line in /etc/portage/package.keywords file:

>=dev-util/eclipse-cdt-2.0 ~x86

Now do the emerge:

sh# emerge eclipse-cdt

More information on installing java 1.5 and eclipse 3.x on Gentoo OS.