Previous INDEX Next
Docbook Stylesheets Web Publishing using make

Installing Java on Debian Testing

I used to have Sun's J2SE environment under the Redhat version of Linux. Shortly after migrating to Debian, I had investigated the installation of Java. However, it seemed that the Debian had licensing problems with Sun's Java platform, so I didn't pursue it further.

Later, the absence of JVM support in Mozilla was making it a little difficult to check that my web-site's applets were working. I therefore re-opened the investigation into Java support on Debian. With a little more time to spend I read further into the Debian Java FAQ. I discovered that this FAQ contains a very useful description of how to get the Sun J2SE environment working under Debian (and specifically of interest to me, Debian Testing). What follows is therefore more-or-less a duplication of the relevant sections of the FAQ, supplemented by content from a page submitted by Brandon Phillips on Open Source Lab's wiki, documentation and knowledge site, which was placed here for my handy reference (but now, in 2016, no longer exists).

Here's the steps the install Sun J2SE on Debian Testing:

  1. Download the J2SE (and documentation) from Oracle (nee Sun), into a convenient location (e.g. /var/install/java). At the time of writing, the latest version is 1.4.2_04. The J2SE installer is run as a shell script, so you can run it by:
              cd /var/install/java
              sh ./j2sdk-1_4_2_04-linux-i586.bin
            
    This will create a new directory j2sdk-1_4_2_04 under the /var/install/java directory.
  2. Move the newly created j2sdk-1_4_2_04 directory to /usr/local/lib and create a link. (You need to be root to do this).
              mv /var/install/java/j2sdk-1_4_2_04 /usr/local/lib
              ln -s /usr/local/lib/j2sdk-1_4_2_04 /usr/local/lib/jdk
              chown -R root:src /usr/local/lib/jdk # necessary?
            
    The creation of the link is not necessary, but it means you can refer to /usr/local/lib/jdk always, and still continue to upgrade to new versions.
  3. So far, nothing new here. This is where the Debian bit really starts. First, the following Debian packages need to be installed. This is really to provide us with the dummy package control files, and the equivs facility, needed in the next step. Note we install kaffe at this point as well.
              apt-get install kaffe equivs java-common java2-common
            
    This step will cause the installation of the kaffe Java platform, the Debian default.
  4. Since Debian does not have installer packages for Sun's J2SE, a dummy package needs to be made to let Debian know that a J2SE is installed. This is done as follows. Use the 'dummy' package control files provided by java-common to satisfy dependencies.
              mkdir -p /var/install/java/pkg
              cd /var/install/java/pkg
              cp /usr/share/doc/java-common/dummy-packages/*.control .
              equivs-build java-compiler-dummy.control
              equivs-build java-virtual-machine-dummy.control
              equivs-build java1-runtime-dummy.control
              equivs-build java2-compiler-dummy.control
              equivs-build java2-runtime-dummy.control
            
    You should now have five packages in /var/install/java/pkg that should be installed.
              dpkg -i java-compiler-dummy_1.0_all.deb
              dpkg -i java-virtual-machine-dummy_1.0_all.deb
              dpkg -i java1-runtime-dummy_1.0_all.deb
              dpkg -i java2-compiler-dummy_1.0_all.deb
              dpkg -i java2-runtime-dummy_1.0_all.deb
            
  5. Since Debian supports a multiplicity of Java platforms, the update-alternatives technique is used to determine which binaries should be invoked.
              update-alternatives --install /usr/bin/javac javac \
                    /usr/local/lib/jdk/bin/javac 500
              update-alternatives --install /usr/bin/java java \
                    /usr/local/sun/jdk1.X/bin/java 500
              update-alternatives --install /usr/bin/appletviewer appletviewer \
                    /usr/local/lib/jdk/bin/appletviewer 500
            
    These command set up the Sun binaries for javac, java and the appletviewer. The use of the priority, 500, will ensure that Sun binaries are used in preference to the kaffe binaries installed as part of step 3.
  6. Run java as root to allow the system preference directories to be set up, and to check that the right version of java is invoked.
              java -version
            
  7. Finally, to ensure Mozilla can use the JVM plugin, create a link from the Mozilla plugin directory to the actual location with the newly installed Sun Java directories.
              ln -s \
                /usr/local/lib/jdk/jre/plugin/i386/ns610-gcc32/libjavaplugin_oji.so \
                /usr/lib/mozilla/plugins/libjavaplugin_oji.so
            
Previous INDEX Next
Docbook Stylesheets Web Publishing using make