Whole document tree
    

Whole document tree

Debian Java FAQ. - Running Java in Debian
[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ next ]

Debian Java FAQ.
Chapter 8 - Running Java in Debian


8.1 Do it yourself

If the releases provided aren't recent enough for you, you can of course install the file from the Blackdown mirrors. You can either use the Debian packages provided by Blackdown or download their tar files.

(contributed by Federico Mennite) If you want to use their packages, add the following line to your /etc/apt/sources.list (use potato or woody depending on the Debian release you are running):

     deb -mirror-debian potato non-free
     deb -mirror-debian woody non-free

Where -mirror- is one from the list available at http://www.blackdown.org/java-linux/mirrors.html. And then do:

     $ apt-get update
     $ apt-get install j2sdk1.3

(contributed by Paul Reavis) If you download and install the JDK tar.gz files, unpack them into /usr/local/jdk1.1.x, and use symlinks to create a /usr/local/jdk and link in binaries to /usr/local/bin or whatever. It is not at all difficult to install these. However, you can get segfaults under some conditions depending on your libraries.

Here is a list of releases that are known to work under each Debian release, and what other software needed, if any, to make it happen.

  • rex/bo: 1.1.5v7 (libc5).
  • hamm:1.1.5v7 (glibc), also needed latest glibc from slink.
  • slink: 1.1.6-test2 (glibc).

8.2 Making swing work in Debian

(from Paul Reavis) [A quickie on getting Swing working under Debian or any Linux really]

Yes, it does work with the linux JDK; Swing is 100% Pure Java (tm)(c)(SFD) and therefore should run under any compliant JVM. Paul Reavis reported converting a commercial app (350+ classes) over to a fully-Swing GUI; I've had no problems so far.

If you are using jdk 1.1.3 ore below, all you need are the class files. So, the easiest thing to do is grab the solaris distribution, in tar.Z format, from javasoft. Depending on phase of moon, they either call it swing or JFC 1.1 (to distinguish from 1.2, which is part of Java 1.2). The current version is Swing 1.0.2 (not to be confused with Java 1.0.2!). If you are using jdk 1.2.2 do not download Swing (it is already integrated in the jdk).

I don't have the archive handy here, so we'll pretend it's named swing.tar.Z. It is recommended you install it in /usr/local. So

             skronk# cd /usr/local
             skronk# tar xzf /tmp/swing.tar.Z

Now you should have a /usr/local/swing directory. To test, make sure your JAVA_HOME variable is set, and CLASSPATH is unset, and run the "runnit" script in each example. To be painfully obvious, do this:

             skronk$ cd /usr/local/swing/examples/SwingSet
             skronk$ echo $JAVA_HOME
             /usr/local/jdk
             skronk$ unset CLASSPATH
             skronk$ echo $CLASSPATH
     
             skronk$ ./runnit

Of course, your directories, shell prompt, and mileage will vary. To use with your own applications, just add the jars you want to your classpath.


8.3 Making Java 2 work in Debian

If you wish to use Sun's or Blackdown's jdk 1.2 in Debian download the packages provided by Blackdown (they are available in aptable directories) from the different mirrors available in http://www.blackdown.org/java-linux/mirrors.html (check the debian subdir). Currently there are i386 packages for the Java2 SDK and RE, JAI, Java3D and JMF.

Or you can use the following mechanism:

  • Make a directory under /usr/local (for example /usr/local/sun).
  • Download the archine into this directory, then unpack it. A directory jdk1.2.2 will be created.
  • Adjust the alternatives to work correctly:
            update-alternatives --install /usr/bin/javac javac usr/local/sun/jdk1.2.2/bin/javac 120
            update-alternatives --install /usr/bin/java Java usr/local/sun/jdk1.2.2/bin/java 120
    
  • Check your alternatives with "type"
            type javac
            type java
    

You should have now a fully working jdk 1.2 environment, virtual machine and compiler included.

You might need to change your /etc/profile adding:

     # JDK 1.2.2 (.tar)
     export CLASSPATH=.:/usr/local/sun/jdk1.2.2/lib:/usr/local/sun/jdk1.2.2/jre/lib
     export JAVA_COMPILER=javacomp
     export JAVA_HOME=/usr/sun/local/jdk1.2.2
     export PATH=$PATH:/usr/local/sun/jdk1.2.2/bin

Note: As Juergen Kreileder correctly pointed me out The preferred name for versions >= 1.2 is Java 2 SE (Standard Edition). The jdk1.3 now is called "Java2 SDK v1.3" or "J2SDK 1.3". The jre1.3 now is called "Java2 RE v1.3" or "J2RE 1.3".


8.4 Is there a way, using free software, to run a Java program in Debian?

Yes there is, since the problem currently now is the jvm you can try to run applications without a jvm. How? Compiling to native code is the solution.


8.4.1 How do I compile to native code?

You might be able to use gcj or jikes (both free programs), to compile the program. And use gcj to convert bytecode to native code. The entire sofwtare chain is free.


8.4.2 Are there any successes using this approach?

Most certainly, read in http://www.debian.org/Lists-Archives/debian-java-9911/msg00044.html how this was done for the XML parser xp.

     ezili:~/infosystems/XML/Java> gcj --main=UnTag UnTag.java UnTagHandler.java 
     /usr/share/java/repository/org/xml/sax/helpers/*.class 
     /usr/share/java/repository/org/xml/sax/*.class /usr/share/java/repository/com/j
     clark/xml/sax/*.class /usr/share/java/repository/com/jclark/xml/parse/*.class 
     /usr/share/java/repository/com/jclark/xml/tok/*.class 
     /usr/share/java/repository/com/jclark/util/*.class 
     /usr/share/java/repository/com/jclark/xml/parse/base/*.class

8.4.3 Are there any problems with this approach?

Yes there are also some problems.

gcj does not fully support JNI. Tom Tromey is responsible for the JNI implementation. As of april 2000 it is missing one feature (you can't currently compile a .class file that uses JNI functions to implement its native methods), but Tom is working on this and hope to have it completed "soon".

Lack of JNI affects use of Classpath (e.g. as an alternative to libgcj) as well as small, standalone apps that replace AWT with some really simple GUI (like using curses, e.g. for small installers). It also affects projects which have native code for performance reasons. At the moment, gcj basically forces a CNI port. The only alternative we are aware of is TowerJ, which is good for commercial projects, but does not offer anything to free software.


8.4.4 Does these work for architectures different than i386?

Possibly not, since libgcj does not build on sparc and no one has tried this for arm.


8.5 Other Java programs not yet available on Debian

The following are programs that have not yet been packaged for Debian nor is there an installer. There are quite a lot Java programs out there and this list is not an exhaustive list, it only includes programs that might be packaged for Debian or those that someone is working on an installer for:

.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ next ]

Debian Java FAQ.

1.0 7 April 2002Thu, 7 Dec 2000 19:10:13 +0100
Javier Fernández-Sanguino Peña jfs@computer.org