(Ripped from my post on knoppix.net a couple of months ago)
Sun does not use an open license for Java so it is not included with the official Debian archives, so you can't apt-get install with a stock /etc/sources.list file.
However, the Blackdown project (blackdown.org) provides Java packages for Debian (and many others). These are not very up to date (usually) so I just download the Java SDK (not the JRE!) from Sun and install it.
Here's how you do it:
1. Download the "Linux self-extracting file" package from http://java.sun.com/j2se/1.4.2/download.html
2. Create a directory for Java related stuff under /usr/local:
$ cd /usr/local
$ su (enter password for root, note that the prompt changes when you're root)
# mkdir java
# cd java
3. Then you need to run the file. With this file you can do it like this:
# sh j2sdk-1_4_2_01-linux-i586.bin
....or like this:
# chmod +x j2sdk-1_4_2_01-linux-i586.bin (this makes the file executable)
# /home/hw/downloads/j2sdk-1_4_2_01-linux-i586.bin (execute it - run this from the /usr/local/java directory)
4. Now it's installed. Still, the java and javac commands won't work from the command line because the /bin subdirectory from the SDK isn't in the path. We need to add them somehow. There are many different ways of doing this but this is how I usually do it:
Edit /etc/profile (as root) with your favourite text editor. There should be a line that specifies directories that contain executables and should be added to the PATH environment variable. Something like this:
The directories are separated by colons (":"). Add a colon at the end of the line (but before the closing quote) and add the Java bin directory. If you followed my outline above it should be /usr/local/java/j2sdk1.4.2/bin/.
Now the line looks like this:
Save the file!
Either log out and log in again or do a "source /etc/profile" to let the changes take effect. Type "javac" at the shell prompt and you should see the exact same thing as you see on Windows!
Håkan (a.k.a. hw, a.k.a. hw-tph, etc)