Outdated
As the comments suggest this document is now outdated. A much more streamlined way to install Java is to:
- Grab: http://java.sun.com/j2se/1.5.0/download.jsp

- apt-get install java-package fakeroot
- fakeroot make-jpkg jre-1_5_0_02-linux-i586.bin
- dpkg -i sun-j2re1.5_1.5.0+update02_i386.deb
- logout and login again and check java
- java -version
More information on this method can be found here:
http://serios.net/content/debian/java/with-java-package.php
Historical Documentation (still useful for Woody)
The following document should lead you by the hand and help you install Java on your box. The reason this isn't a script is because the Java installer seems to change every version, and it doing it by hand is a stepping stone to installing alternative JVMs. So hopefully you get a working install and learn a little about Debian and Java while doing it.
Grab the Java SDK
Sun Java J2SE SDK
(1.4.2_04) You want the SDK and Documentation
Installation
Note: Substitute correct version numbers for packages and files when installing future versions.
Upgrade Debian to the latest packages
apt-get update
apt-get -u upgrade
apt-get -u dist-upgrade
Install Debian packages for handling unpackaged software.
apt-get update
apt-get install kaffe equivs java-common java2-common
Install Java SDK
- Download J2SE SDK components to
- Change to install dir:
cd /var/install/java/1.4.2
- Make sure you have write permissions to the directory.
- Make installer executable:
chmod a+x j2sdk-1.4.2_04-linux-i586.bin
- su to root:
- Run the installer:
./j2sdk-1.4.2_04-linux-i586.bin
This will create the directory j2sdk1.4.2_04 with many files and directories in it.
- Unzip the docs (you did download the docs from the Java website didn't you?):
unzip j2sdk-1.4.2-doc.zip
This will create the directory docs.
- Move the docs into the SDK:
- su to root:
- Change the ownership of the java files:
chown -R root:src j2sdk1.4.2_04
*Note: root should own all system files like java. The group src is short for source as in code. That's the group we are using for users allowed to compile source code.*
- Move the SDK directory tree to the final runtime location:
mv j2sdk1.4.2_04/ /usr/local/lib/
- Create link:
ln -s /usr/local/lib/j2sdk1.4.2_04 /usr/local/lib/jdk
Note: This link should be used everywhere to refer to the path of the JDK and JRE. Always use /usr/local/lib/jdk... and do not use /usr/local/lib/j2sdk1.4.2_04. This allows easier upgrading in the future and multiple versions of java to be installed simultaneously.
- Tell Debian that java has been installed. Use the "dummy" package control files provided by java-common to satisfy Debian packing dependencies. *NOTE: if you are OSUOSL 'apt-get install java2-compiler-dummy java-compiler-dummy java2-runtime-dummy java-virtual-machine-dummy' and skip to 15.*
cd /var/install/java
mkdir pkg
cd pkg
cp /usr/share/doc/java-common/dummy-packages/*.control /var/install/java/pkg/
equivs-build java-compiler-dummy.control
equivs-build java-virtual-machine-dummy.control
equivs-build java2-runtime-dummy.control
equivs-build java2-compiler-dummy.control
- You should now have 5 packages in /var/install/java/pkg. Install them with dpkg:
dpkg -i java-compiler-dummy_1.0_all.deb java-virtual-machine-dummy_1.0_all.\
deb java2-compiler-dummy_1.0_all.deb java2-runtime-dummy_1.0_all.deb
- Tell Debian to use our new JDK: Run this shell script
* NOTE: The command update-alternatives is used in Debian to choose which of several packages to use when several can do the same thing. ("Java" can be provided by kaffe, blackdown, and Sun, etc.) See "man update-alternatives" for details.*
- Run java once as root (you're still root) to allow system preference directories to be created and check that Sun's java is running: java -version
- Update the JAVA_HOME environment variable and the path in /etc/profile or /home/$USER/.bash_profile or /root/.profile:
export JAVA_HOME="/usr/local/lib/jdk"
export JDK_HOME="${JAVA_HOME}"
export PATH="${JAVA_HOME}/bin:${PATH}"
- To totally reset the environment variables, you need to reboot
NOTE: Leave the directory /var/install/java and its contents. You may need it again later for uninstallation
Mozilla-Firefox Configuration
Run the following command as root:
ln -s /usr/local/lib/jdk/jre/plugin/i386/ns610-gcc32/libjavaplugin_oji.so \
/usr/lib/mozilla-firefox/plugins/libjavaplugin_oji.so
Mozilla Configuration
Run the following command as root:
ln -s /usr/local/lib/jdk/jre/plugin/i386/ns610-gcc32/libjavaplugin_oji.so \
/usr/lib/mozilla/plugins/libjavaplugin_oji.so
Getting Eclipse
apt-get install eclipse-sdk eclipse-source
hello there, thanks a bunch for the article! i'm a newbie and this is actually the first "how to install java on debian" article i could follow
i'm running into problems though...i downloaded the new java 1.5.0 package and everything went smoothly until step number 16: when i tried "java -version" i got a "command not found" message? i tried "whereis java" command and i got
"/usr/bin/java /usr/share/java /usr/share/man/man1/java.1" but when i tried to go to the "/usr/bin/java" directory, my debian told me there was no such directory...
so i thought what the heck, i'll just go ahead with step 17 and 18 , reboot and then configure firefox...
i got a similar message: "there is no /usr/local/lib/jdk...etc. and no /usr/lib/mozilla-firefox...directory"...
can someone help? i was so sure i was finally going to have java this time
thanks!