Installing Java from debian Packages in Debian

Debian Unofficial provides some .deb packaged archives for various things not present in Debian's official repositories, among these the Sun and IBM Java JRE/JDK.

At the time of this writing, the Java versions available from this repository for Debian 3.1 stable ('sarge') are (see their packages list for current information)

Sun JRE/JDK 5.0
32-bit x86
32-bit x86

Edit the APT sources file /etc/apt/sources.list and add a line with a suitable APT repository there. For all the APT sources listed here, you can of course replace the address with some more suitable mirror for your situation, e.g. closer to your location. See the link mentioned above for such mirrors.

# Debian Unofficial
deb sarge main contrib non-free restricted

If you want more mirrors click here

Now you need to run the following command to update the source list

#apt-get update

Package cryptographic authentication

Debian since 'etch' has cryptographic signature checking of the APT sources enabled by default. Thus you may get some warnings and verification questions whether you really want to install packages from this package repository since the key used to sign these packages is not in the list of trusted APT sources by default.

The warning message and question look like this

W: GPG error: sarge Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F82E5CC04B2B2B9E

WARNING: The following packages cannot be authenticated!
Install these packages without verification [y/N]?

If you want to avoid those warnings and questions, you need to add the public key of the one who packaged those, in this case the public encryption key of this author, to APT's list of trusted keys so that the signatures of the packages can be verified against that key.

Remember to never implicitly trust keys from unverified sources, one should always try to verify their legitimity. The below is for convenience only, you should take whatever precautions you find necessary to verify that it is actually the public encryption key of the author of these packages.

Add the public encryption key to APT's list of trusted keys by:

gpg --keyserver --recv-keys F82E5CC04B2B2B9E
gpg --armor --export F82E5CC04B2B2B9E | apt-key add -
Pay attention to the dash at the end of the last command, it must be included also.

And then run #apt-get update again.

Install a Java JRE or JDK in Debian

Install an available version of Java that you like. Remember that the JDK contains the JRE so you don't need to download both.


Java Runtime Environment - If you don't plan to create Java apps yourself, then this is enough.


Java Development Kit - the software development kit (SDK) for Java. If you plan to create Java apps yourself you need the JDK.

The package names for the available JRE/JDK are

Sun JRE 5.0


Sun JDK 5.0






Install the JRE/JDK by executing (sun JRE 5.0) in debian

#apt-get install sun-j2se5.0-jre-binary

Replace the package name in the above command with sun-j2se5.0-jdk-binary if you want to install the SDK instead, and or sun with ibm if you want the IBM ones instead.

Verify your installation

To verify that the installation was successful, execute

#java -version

The output should look something like this if everything is well

java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode)If the version does not match what you just installed, and you had a JRE/JDK installed previously, keep on reading below.

Multiple JRE/JDK installed

If you have multiple JRE or JDK installed (e.g. 1.5.0 and 1.4.2) and want/need to switch between them, you can use update-alternatives to do so.

Choosing which java executable to use:

#update-alternatives --config java

Choosing which javac executable to use:

#update-alternatives --config javac

And so on in that fashion for the remaining executables related to Java. You can look in /etc/alternatives to see what one can configure with update-alternatives.