Dec 15
HOWTO: Packaging Java 6 for Ubuntu
Update: As of Fri 19th Jan 07 Java 6 has now been officially included into the Dapper Backports repository. See it’s package page.
Today I found out how to package Java for Ubuntu/Debian. I wanted to see if a .deb package file of Java 6 was available for Ubuntu I found details on creating one in the following forum post: Re: JDK 6 Available…now when is a deb coming?. The instructions there are great except they don’t work perfectly for Dapper so here are the modified steps for Dapper:
1) Patch ‘java-package’
The Debian Java Maintainers have created a tool make-jpkg which is a neat script to take the Sun Java native linux .bin installer and turn it into a .deb package. This script comes in the ‘java-package’ package which is in the multiverse repo in Ubuntu.
Dapper stocks the 0.27 version which does not support conversion of Java 6 yet. However, mlind attached a patch to his forum post (link above) to add support for Java 6 to java-package version 0.28. Luckily it’s not difficult to tweak the patch for 0.27. Here’s the modified version of the patch:
java-package_sun-java6.dapper.patch
Here’s the instructions on how apply the patch and build the updated package:
-
-
mkdir java-package
-
cd java-package
-
sudo apt-get build-dep java-package
-
apt-get source java-package
-
cd java-package-0.27
-
patch -p1 < ../java-package_sun-java6.dapper.patch
-
debuild -b -us -uc
-
cd ..
-
sudo dpkg -i java-package_0.27local0_all.deb
2) Package sun-jdk6
Now that you’ve updated java-package it’s time to package Java 6. First download Java 6 from Sun. You need to download the Linux self extracting file (jdk-6-linux-i586.bin). Here are the instructions on building it (taken from the forum post listed above).
-
-
mkdir sun-jdk6
-
cd sun-jdk6
-
# put jdk-6-linux-i586.bin into this directory
-
make-jpkg jdk-6-linux-i586.bin
-
dpkg -i sun-j2sdk1.6_1.6.0_i386.deb
-
sudo update-alternatives –config java
-
# select the new Java 6 installation as the provider of java
-
java -version
-
# Output of the above command should be
-
# java version "1.6.0"
-
# Java(TM) SE Runtime Environment (build 1.6.0-b105)
-
# Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

January 2nd, 2007 at 3:30 pm
I tried to follwo your guide, but failed in one of the last steps:
Now signing changes and any dsc files…
signfile java-package_0.27local0_i386.changes Dan Munckton
gpg: keyring `/home/iznobad/.gnupg/secring.gpg’ created
gpg: skipped “Dan Munckton “: secret key not available
gpg: [stdin]: clearsign failed: secret key not available
debsign: gpg error occurred! Aborting….
debuild: fatal error at line 1151:
running debsign failed
Apparently i need some gpg key from you….
Anyway. Since you made the deb package already, could you provide it for us deb newbies?
January 3rd, 2007 at 8:07 pm
Hi Iznobad
Thanks for the feedback. To build the deb without signing it add the -us and -uc options to the debuild command.
debuild -b -us -uc
I’ve updated the post with these options. I’ll try to put the debs somewhere for download soon.
January 8th, 2007 at 8:01 pm
Thanks a lot for this guide, in the 7th step I made the slight modification:
debian/rules binary
But that’s mostly out of preference, works like a treat - cheers
January 15th, 2007 at 10:06 pm
I have just moved from XP to Ubuntu and I searched web for JDK6 installation HOWTOs and seems that your blog is the best : simple, clear, complete, and it really works
Thanks.
January 27th, 2007 at 12:34 am
I am getting a “java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory” error after the install. Any ideas?
January 31st, 2007 at 9:53 am
SnowX: I found a forum post about it here, the guy seems to have been making a manual install and made a mistake as he was linking the ‘java’ command into his path.
the ‘java’ command will have been linked relative to the libjli so if the relative path from the ‘java’ binary to the lib is wrong the system won’t be able to hook the two up at runtime.
I recommend you check the results of the ‘update-alternatives’ command and make sure the correct files (i.e. the new jdk6 ones) are linked on the path ok.
Useful commands to explore this would be:
$ which java
/usr/bin/java
$ file /usr/bin/java
/usr/bin/java: symbolic link to `/etc/alternatives/java'
file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/j2sdk1.6-sun/bin/java'
$ file /usr/lib/j2sdk1.6-sun/bin/java
/usr/lib/j2sdk1.6-sun/bin/java: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
$ ldd /usr/lib/j2sdk1.6-sun/bin/java
linux-gate.so.1 => (0xffffe000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7f6b000)
libjli.so => /usr/lib/j2sdk1.6-sun/bin/../jre/lib/i386/jli/libjli.so (0xb7f61000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7f5e000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e2f000)
/lib/ld-linux.so.2 (0xb7f92000)
The last command ‘ldd’ lists out the libraries which are linked to the ‘java’ command - notice libjli.so is listed and it shows the path to libjli relative to the java binary.
Hope that helps.
May 1st, 2007 at 10:45 pm
You can now get sun-java6 via the dapper-backports repository.