Dashboard > Development > Java on Debian
Development Log In   View a printable version of the current page.
Java on Debian
Added by Brandon Phillips, last edited by Brandon Philips on Jun 29, 2005  (view change)
Labels: 
(None)

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

  1. Download J2SE SDK components to
    /var/install/java/1.4.2
  2. Change to install dir:
    cd /var/install/java/1.4.2
  3. Make sure you have write permissions to the directory.
  4. Make installer executable:
    chmod a+x j2sdk-1.4.2_04-linux-i586.bin
  5. su to root:
    sudo su
  6. 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.
  7. 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.
  8. Move the docs into the SDK:
    mv docs j2sdk1.4.2_04
  9. su to root:
    sudo su
  10. 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.*
  11. Move the SDK directory tree to the final runtime location:
    mv j2sdk1.4.2_04/ /usr/local/lib/
  12. 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.
  13. 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
  14. 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
  15. 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.*
  16. 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
  17. 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}"
  18. 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
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.7 Build:#524 Jul 28, 2006) - Bug/feature request - Contact Administrators