Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(‘The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

April 1, 2006

Java 1.5 and Eclipse in Gentoo – Part II

Filed under: GNU/Linux, Gentoo, Java — tabrez @ 12:48 pm

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:

sh# java-config -L

[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# java-config -S blackdown-jdk-1.4.2.03
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# java-config -s sun-jdk-1.5.0.06
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# chmod +x jdk_1_5_0_06-linux-i586.bin
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# source ~./bash_profile
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.

Adding a New JRE

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.

Selecting the default JDK version

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).


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Java on Gentoo
  • EasyEclipse is the Best Packaged Distribution of Eclipse Platform
  • Two Applications For Easy Management Of ‘USE’ Flags In Gentoo
  • How to Speed up Booting Into GNOME – A Gentoo Wiki Tip
  • C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW
  • Develop Ruby Applications Using Eclipse IDE
  • Should I Be Developing Ajax Applications using Google Web Toolkit(GWT)?


  • 4 Comments »

    1. [...] 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] [...]

      Quote

      Pingback by Every Flavour Beans » Java on Gentoo — May 10, 2006 @ 5:50 pm

    2. 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.

      Quote

      Comment by Sri Raguraman — December 9, 2006 @ 12:18 am

    3. Glad to hear that! I am always on the lookout for the people who are using Gentoo, my favourite operating system :)

      Quote

      Comment by tabrez — December 10, 2006 @ 3:06 pm

    4. Thanx for this post – much helpful. Minor typo error above – should be ~/.bash_profile

      Quote

      Comment by Paul Hewlett — December 18, 2008 @ 8:22 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost