If you are looking for an integrated, java virtual machine, compiler and runtime environment, then Debian does provide them, and there are quite a lot of projects you can choose from, that are included in Debian:
- kaffe: http://www.kaffe.org
- gcj/libgcj: http://sourceware.cygnus.com/java/
- jikes: http://www.research.ibm.com/jikes/
- kopi: http://www.dms.at/kjc/
- FastJar http://fastjar.sourceforge.net/ ,etc.
but you will not find Sun’s Java 2 SE (JDK/JRE) included in Debian because of its restrictive license policy.
So if you need to use Sun’s JDK, you will have to manually install it. Actually this is very simple, as you just have to download the binary self-extracting package from Sun’s site and just execute it. So why would you want to create a deb (debian package)? Well maybe you will have to install it on several machines (maybe using a local apt repository) or maybe you just want to ease future upgrades, or just for fun… :–).
For building our own Sun Java deb’s we will use the debian tool make-jpkg. This will allow us to build in the exact same way as presented here the following packages: blackdown-j2re, blackdown-j2sdk, ibm-j2re, ibm-j2sdk, j2re, j2sdk, j2se, sun-j2re, sun-j2sdk. To exemplify this I will build the deb for sun-j2sdk, but will give short notes for JRE also.
Install fakeroot / java-package
Ok. The first thing you need is to install make-jpkg. Depending from the state of your system and applications/libraries already installed you might see different things from my examples… just ignore that, it is normal… For the record, I am using for this a Debian testing (Etch) system.
apt-get install fakeroot java-package
in case this will not find java-package make sure that you have in your apt sources the contrib repository where this lives, like
/etc/apt/sources.list deb ftp://ftp.debian.org/debian/ etch main contrib
This will install its needed dependencies that are not available on your system. For example you can see something similar added to your system: debhelper gettext html2text intltool-debian libcompress-zlib-perl libmail-sendmail-perl po-debconf unzip
Download the Java package from Sun’s site
The next step is to get the appropriate java package (JDK or JRE) for your system. Go to http://java.sun.com/javase/downloads/index.jsp and choose either: JDK 5.0 Update 7 or Java Runtime Environment (JRE) 5.0 Update 7 download links (the versions are obviously the ones available when writing this post, so they might differ). Next review and if you want to continue accept the license and select the proper file to download. This will look like: For JDK: jdk-1_5_0_07-linux-i586.bin or jdk-1_5_0_07-linux-amd64.bin (depending on your system architecture) For JRE: jre-1_5_0_07-linux-i586.bin or jre-1_5_0_07-linux-amd64.bin (depending on your system architecture)
Once you have downloaded the needed file locally on your system you are ready to move on.
Building the deb package
In case you are running as root, you will need to switch to a regular user for the actual build (if not the java-package will complain about this being able to change system files in /etc and will exit with an error). Now as a regular user you will just have to run:
fakeroot make-jpkg jdk-1_5_0_07-linux-i586.bin
(using the actual java package you have downloaded). For jre use fakeroot make-jpkg jre-1_5_0_07-linux-i586.bin
Here is an example output from a JDK build:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
As you can see, you only have to follow the instructions: press Y to start, accept license (type yes) and you are done (basically the same as on a manual install of the binary package).
Once this will finish you will end up in the working directory with a deb package sun-j2sdk1.5_1.5.0+update07_i386.deb (or sun-j2re1.5_1.5.0+update07_i386.deb for JRE).
Now you can install it using dpkg:
dpkg -i sun-j2sdk1.5_1.5.0+update07_i386.deb
or for JRE: dpkg -i sun-j2re1.5_1.5.0+update07_i386.deb or place the files in your local apt repository if that is the case, and install them using apt:
apt-get install sun-j2sdk1.5
or for JRE: apt-get install sun-j2re1.5
Note: when the deb is build you might see several missing dependencies complains (from dpkg-shlibdeps). I am not really sure (and I didn’t had the time to test this) if this is really needed or not but it might be a good idea to install the missing dependencies that you might see before the final build. The packages missing might look like the ones from bellow:
I hope you enjoyed this post and found it useful. If you feel that this post can be improved or it is missing some information please use the comment form to let me know.