Packaging Java 6 for Ubuntu
Posted: 2006-12-15
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. It wasn’t, but 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
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
Put jdk-6-linux-i586.bin into the sun-jdk6
directory then
$ cd sun-jdk6
$ make-jpkg jdk-6-linux-i586.bin
$ dpkg -i sun-j2sdk1.6_1.6.0_i386.deb
Now select the new Java 6 installation as the provider of java
$ sudo update-alternatives --config java
$ java -version
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)