The good way to configure Java in Ubunto

After I wrote the previous post, I found out I should not have configured Java like that. So after following some tips from the comments and from “Installing Sun’s Java environment in Debian systems” here is a better way to do it:

  • Go Repositories/Ubuntu where you will find information on how to add the “Universe” repository.
  • Open your Synaptic Package Manager and search for java-package. Mark for install and apply.
  • After downloading the JDK bin file, go to a terminal and type
  1. make-jpkg jre-1_5_0_03-linux-i586.bin
  2. sudo dpkg -i sun-j2sdk1.5_1.5.0+update09_i386.deb
  3. sudo update-alternatives –config java (here choose the one that points to the JDK you installed)
  4. sudo update-alternatives –config javac

This is a better way since it will take care of the system variables for every user (you can verify that java and javac are working on the console) and it will be easier to manage updates.

If you’re using Eclipse you need to update the Installed JREs in Window->Preferences->Java and add a new one that points to /usr/lib/j2sdk1.5-sun/ e.g..

5 thoughts on “The good way to configure Java in Ubunto

  1. Hi Ana,

    You could also (once you’d added universe) typed ‘apt-get install sun-java5-jdk’.
    Sun java packages have been available for ubuntu for a while.

  2. From what I could see, update-alternatives modifies the symbolic links in /etc/alternatives.

    e.g. /usr/bin/java is a symlink to /etc/alternatives/java, which in turn is a symlink to the chosen java binary, which is /usr/lib/jvm/java-1.5.0-sun/bin/java on my machine

    And as Wouter said, all this is done with a simple ‘sudo aptitude install sun-java5-jdk’ now (you still have to to enable universe/multiverse repositories, though).

Leave a reply to Hogmoru Cancel reply