Sunday, December 11, 2005

Debian/Ubuntu HOW-TO: Sun's Java

Last revision : April 28th, 2007

Installing Java from Sun is very easy in Debian.

Here is the simplest way. First a section for Debian Etch users, then the explanation for Debian Sarge.

  • Installation

On Debian Etch

On Debian Etch the installation is incredibly simple. On you made sure you have the non-free repository enabled, just type:

sudo apt-get install sun-java5-jre

For the Java browser plugin, you will the package sun-java5-plugin as well:

sudo apt-get install sun-java5-plugin

For Debian Etch, nothing more is needed.

On Debian Sarge

On Debian Sarge, as no pre-build packages exist, we need to create our own. Still, quite simple.

Browse to the download section of java developer's site.

Click on Download near Java Runtime Environment (JRE) 5.0 Update 11

Click on Accept License Agreement

Click on Linux self-extracting file and download the file.

Install the needed packages :

sudo apt-get install fakeroot java-package

Build a custom package using the java installer :

fakeroot make-jpkg jre-1_5_0_11-linux-i586.bin

...answer all the questions with the default answers.

Install your custom package :

sudo dpkg -i sun-j2re1.5_1.5.0+update11_i386.deb

That's it, your Mozilla or Mozilla Firefox browsers will now be java-enabled.

  • Tips

Test your Java Virtual Machine directly on Sun's website

You can verify that Sun's Java is effectively the default Java on your system :

java -version

Which should output something like that :

java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)

If that is not the case, then make it default with this command :

sudo update-alternatives --config java

and choose JRE.


Anonymous said...

How to uninstall sun java from our debian or updating our java, from example from 1.5 (Tiger) to 1.6?


Hugues said...


Using this java-package method, the resulting package (from JDK) is called sun-j2sdk1.5, so you can uninstall java by removing it :
apt-get remove --purge sun-j2sdk1.5

As of now, java-package doesn't support Sun's Java 6 (1.6). You'll have to wait a little, or search for some home made patches to the program (there are many out there).

Also, you can install Java using the classical method, described on Sun's site :

Good luck !

Anonymous said...

That was very useful. Thank you very much.

vad said...

what about etch 64?
does this works?

Hugues said...

Hi Vad,

If the Etch method doesn't work (I guess it should), use the Sarge method with the AMD64 version of Java from Sun's site (with java-package).

Thanks for your comment,