Hassle-free installation of Sun JDK on Debian

Normally we download Sun JDK installation binaries and install them. Then we configure the PATH environment variable to point to our JDK installation. But some times there will be conflicts between the native gcj and Sun JDK. So it is always better to install Sun JDK through debian repositories.

But unfortunately, the Debian repositories have Sun JDK in non-free repositories and do not always have the latest JDK.

So this is how we can install the latest JDK natively on Debian.

Steps to be followed:

1. We have to download the JDK or JRE binaries (a .bin file) appropriate for our architecture.

2. Then we have to create a .deb package from the Sun JDK binaries we have downloaded

*Requirements:

a.Install java-package which will help us to convert the Sun JDK .bin file to a  .deb file installable on Debian.

b. Install fakeroot.

3. Then do as non-root user,

fakeroot make-jpkg <Sun JDK binary filename>

If there is an error like ‘Plugins not found’ or similar errors, it means that the version of the Sun JDK you are trying to install may not be supported by ‘java-package’. Fortunately, there is a work-around for this:

Edit usr/share/java-package/sun-j2sdk.sh like this:

Add the following to that file:

"<Your Sun JDK/JRE bin file name") # SUPPORTED
j2se_version=1.6.0+update<version>${revision}
j2se_expected_min_size=130
found=true
;;

at the end of the list of similar directives for various versions of JDK/JRE and save the file.

Now repeat step 3 and it will not give the ‘Plugins not found error’ and a .deb package will be created with some warnings which you can ignore safely.

4. Then install the .deb file as a root user by the command:

dpkg -i <generated .deb file name>

5. After the JDK is installed, we have to configure the installed Sun JDK as the default JDK. So we use the following commands:

update-alternatives –config java

This command will show a list of Java installations available (including gcj) and prompt for a choice.

Choose the choice which corresponds to your Sun JDK installation. In my case it was something like this:

/usr/lib/j2sdk1.6-sun/bin/java

Now your Sun JDK installation will be the default JDK. 🙂

2 Comments on "Hassle-free installation of Sun JDK on Debian"


  1. Hi,

    I really don’t know installing JDK is worth this trouble. But again, right from debian etch, installing the *.bin installer for JSK is strainght forward. At least, it was so for me.

    For all those who prefer to use IDEs, installing the latest version of Netbeans+JDK bundle will be the easiest thing to do. There, things are done automagically 😉

    Reply

    1. To avoid conflicts with gcj and setting the PATH variable, this method will be useful. And though sun-java is available on the debian repositories, it is only available in the ‘non-free’ repositories and that the available version is not the latest. Still there are people who would like to install JDK from the debian repositoris and still have the latest JDK. For such people, this post will be useful. 🙂

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *