Set up VM
Although these instructions produce packages compatible with Debian 5.0 Lenny and 6.0 Squeeze, the package itself can only be built on Debian 7.0 Wheezy (the testing distribution at the time of writing).
You need to use a 32-bit VM to produce 32-bit packages or a 64-bit VM to produce 64-bit packages.
Download a netinst image from http://www.debian.org/devel/debian-installer/ and use it to install a VM.
Make sure that contrib is enabled in /etc/apt/sources.list:
deb http://ftp.uk.debian.org/debian/ wheezy main contrib deb-src http://ftp.uk.debian.org/debian/ wheezy main contrib deb http://security.debian.org/ wheezy/updates main contrib deb-src http://security.debian.org/ wheezy/updates main contrib
Update apt's package list and install java-package:
apt-get update apt-get install java-package
Download Oracle Java SDK
Download the .tar.gz from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html . Choose the Linux x86 or Linux x64 version depending on whether your server is running 32-bit or 64-bit GNU/Linux.
Convert it to a Debian package. This must be done as a non-root user. Note that java-package uses the filename to recognise the version of Java, so if your file doesn't end in .tar.gz (for example because your web browser changed it) then you must rename it before running java-package (see /usr/share/java-package/oracle-j2sdk.sh for more details on what filename patterns java-package recognises as Oracle Java SDKs):
mv jdk-7u17-linux-x64.gz jdk-7u17-linux-x64.tar.gz make-jpkg jdk-7u17-linux-x64.tar.gz
You will be asked a couple of questions, then lots of things will scroll past and finally a .deb should be written to the current directory named something like oracle-j2sdk1.7_1.7.0+update17_amd64.deb. This can be installed by running the following command as root:
dpkg -i oracle-j2sdk1.7_1.7.0+update17_amd64.deb