Java Installation (jdk jre) in Debian

What is Java?

Java is a strongly-typed platform-independent object-oriented programming language often associated with the World Wide Web. Java was developed by Sun Microsystems for embedded applications, but has since grown to become a general-purpose programming language. Java source code can either be compiled to a machine-independent byte-code that can be run by Java virtual machines, or it can be compiled directly to executable code for any number of platforms, including Linux, Win32, and others.

A common API, shipped with all Java development environments, provides socket support, a graphical user interface widget set, graphical drawing tools, standard IO, events, math, database interfaces, and multithreading, to name a few.

The multithreading support can happen either in kernel threads or userland threads, depending on the implementation of the Java virtual machine used. Of course, Java is also the name of a popular island of Indonesia.

Installing java With java-package/make-jpkg

The installation method described in this document uses the java-package and related packages to create a .deb package of the Sun and Blackdown JRE/JDK .bin self-extracting archives, or the IBM JRE/JDK .tgz archives.The java-package is present in the contrib, section, make sure it is included in your APT sources ( /etc/apt/sources.list )

Example for Debian 3.1 'sarge'

deb sarge main contrib non-freeAfter making sure of that, execute

#apt-get update  to make sure the lists of the available packages are up to date.

Download Java

Download a suitable 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.

Proceed to the website of Sun, IBM or Blackdown to download a Java version that you want and that is available for your hardware architecture.

Sun Java 5.0 for 32-bit x86 and AMD64 (the Java 5.0 is also referred to as Java 1.5.0)
Sun Java 1.4.2 for 32-bit x86
IBM Java 5.0 and 1.4.2 for x86, AMD64, PowerPC, PowerPC64, S/390 (free registration required)
Blackdown Java 1.4.2 for 32-bit x86 and AMD64
Blackdown Java 1.4.1 for SPARC
Blackdown Java 1.3.1 for PowerPC

For the Sun Java, click on the link there that says something in fashion of "Download JRE/JDK 5.0 Update 5". Do not choose the link that says "Download JDK with NetBeans Bundle" as make-jpkg does not support creating .deb packages from that one.

Download the option under Linux Platform (or Linux AMD64 Platform for the AMD64 version) that says Linux self-extracting file (the one whose filename ends in just .bin), not the .rpm.bin one.

If the FTP site of the Blackdown Java linked above is slow, go to the Blackdown Java Linux Download Sites page for a list of available mirrors where the files can be downloaded from.

Java for AMD64 version of Debian

You need to be using a 64-bit AMD64 version of Debian to be able to use the Java for the AMD64. If you are using a 32-bit x86 version of Debian on an AMD64 processor using system, download the Java for the 32-bit x86 version.

Also worth noting, the Sun Java 1.5.0 for AMD64 doesn't have the Java web browser plugin currently available, so for browsers that access Java through that plugin, one cannot currently view Java applets with the Sun Java 1.5.0 for AMD64.suggest using the Blackdown Java 1.4.2 for AMD64 if you want to have Java support in such browsers.

Install java-package in Debian

Now install the package java-package which provides the make-jpkg utility for creating the .deb archive of the Java installation file/archive. Execute

#apt-get install java-package

Create the Java deb package with make-jpkg

Create the deb package of the Sun or Blackdown Java self-extracting .bin archive, or the IBM Java .tgz archive by using make-jpkg. In this example the Java 1.5.0 JRE is used. Note to execute this as a normal user by using fakeroot (which was installed as a dependency of java-package) as make-jpkg cannot be executed as root. Also execute the command from the same directory the JRE/JDK .bin/.tgz file is in, or provide the full or relative path to the JRE/JDK .bin/.tgz file.

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

Some warnings may appear during the creation of the deb package. As long as the deb package gets created the warnings are nothing to worry about. The deb package is created in the same directory as the command was executed from.

The created JRE/JDK .deb package's name is in the format of


E.g. sun-j2re1.5_1.5.0+update05_i386.deb for the Sun JRE 5.0 Update 5 for x86, or blackdown-j2sdk1.4_1.4.2+01_amd64.deb for the Blackdown JDK 1.4.2 for AMD64, and so on. To see what exactly the file name your just created .deb package has, check that with the commmand

ls *deb

Install the Java deb package

Install deb package that was created in the above step. Example with the Sun 1.5.0 JRE deb:

#dpkg -i sun-j2re1.5_1.5.0+update06_i386.deb

Of course, replace the filename above with the filename of the deb that you have

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_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)

Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)If the version does not match what you just installed, and you had a JRE/JDK installed previously, keep on reading

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.

Example: Choosing which java executable to use:

#update-alternatives --config java

Example: 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.

If you wish to remove some of the JRE/JDKs you have installed, execute (example: for Sun JRE 1.4.2):

#apt-get remove sun-j2re1.4

Troubleshooting Java Installation in Debian

Errors when issuing make-jpkg

If you encounter problems when issuing the above make-jpkg command, make sure you have the latest version of java-package, currently (2005-11-17) version 0.25 or newer is recommended for everything to go smoothly, but 0.24 should work fine as long as one isn't effected by bug #313555.

With older versions of java-package one may receive an error message that says "No matching plugin was found" when attempting to create a package of the latest Java 1.5.0 (JRE/JDK 5.0 Update 6) or the IBM Java, or get some other errors.

If you are unsure, you can check your version of java-package by issuing the following command

#apt-cache policy java-package | head -2

If you are using Debian 3.1 'sarge' and java-package 0.24 is not working for you, you need to install java-package 0.25 or newer, but that is currently only available in testing ('etch'), so use Apt-Pinning to make packages from 'etch' available, and install java-package from there by

#apt-get install java-package/testing

or if the dependencies of java-package cannot be fulfilled from stable, install with

#apt-get install java-package -t testing