hide random home http://www.wam.umd.edu/~walrus/Amiga-Java.html (Amiga Plus Extra No. 5/97, 05/1997)

World Wide Walrus

Frame-Free Zone

Made With Amiga

Java (Kaffe) for the
AMIGA
Computer

J-J-J-Java!!
The Walrus' Pages
My Amiga at Home
WebLord, the Page Construction Power Tool
Cool Miami Scripts
Under the Hood
Amiga History
Amiga News
Amiga Multimedia
Development

CoolWebSites
Java @ Sun

What is Java?

Have you been living under a rock?! Java is the hottest thing on the internet, gaining momentum at nearly exponential rates. Java is a dynamic, object oriented programming language with roots in C/C++ but an overall better design. Java runs on a computer that is called the Java Virtual Machine, (JVM) most commonly implemented in software to emulate this fictional CPU. Why not compile Java to a native CPU's code? Because the whole idea of Java is platform independence and interoperability regardless of the computer or operating system that you are using!

Isn't emulation of a Java code slow?

Sure it is slower than natively compiled code, but up until recently JVMs have interpreted the Java Byte Code over and over again. Recent advances have introduced Just-In-Time (JIT) compilation to speed-up execution times by a factor of 10 or more. Sun Microsystems, the originator of Java, has recently (July 1997) announced that their next JIT-capable JVM will be as much as 50 times faster than purely interpreted code. This is getting quite close to natively compiled code!

And sooner or later similar performance will come to the Amiga, too.

Is Java available for the Amiga?

Yes, it is! Alas, no effort has as yet succeeded in bringing a JVM to the Amiga with all the classes required to run everything that the "big boys" are running. There is, however, a freely distributable Java Virtual Machine (JVM) called Kaffe that comes with both a java compiler (javac) and the ability to run your java classes. Alas, the Abstract Window Toolkit (AWT) classes are not yet implemented on the Amiga, so your Java programs cannot do any windowing and graphical stuff. This is especially problematic for applets, which always run in a graphical environment. For now you can still write useful programs such as web servers (check out my Dynamic IP page and see if my java-based web server is running.)

So, what does Kaffe get me?

Kaffe compiles your Java applications (and applets, both .java files) into a Java .class file containing Java Byte Code. This is a totally portable file that can run on any computer with a JVM (provided the required classes are on the machine that needs to run the program.)

Kaffe on the Amiga is currently (end of July 1997) only up to version 0.7.1 and does not (as far as I understand) implement the JIT (Just-In-Time) compilation. Kaffe for many other platforms has advanced to version 0.9.1 now. The Amiga version is bound to catch up fairly soon.

What about MOca and MERAPI ?

MOca is a JVM by Finale Development. MERAPI was recently announced by Haage und Partner. Both are likely many months away from release, but both promise JIT capability and will be integrated into Amiga web browsers to provide Amigoids with all the Java stuff that anyone else can run, and that includes things like Corel's Word Perfect Office, just to name one oft-mentioned Java product that will become a cross-platform application through the use of Java.

Enough! How difficult is it to get Kaffe running?

That depends entirely on whether or not you are still reading this... ah, but you are, aren't you? Good! It shouldn't take you more than 10 minutes from the time you finish downloading the required pieces!

Let's get started at once! Here is how to get the files you need:

  • The latest Amiga version of Kaffe;
    This is available from Fred Fish's (Cronus') FTP site (ftp.ninemoons.com/pub/)... you need to descend into the most recent directories (look for 'ADE' and/or 'GeekGadgets') until you reach a place where there seem to be hundreds of files listed (every second file or so has a .pi extension, which is a Product-Info file, describing the contents.)
  • You also need the Sun class library;
    This file will be just before or after the file.
  • A gunzip and tar program to unarchive the files. These tools are also available in the same directory.
  • At least version 46.0 of the ixemul and ixnet libraries. I got the v46.1 versions of both of these from the ixemul... archive, also from there.

Create yourself a nice development directory for your Java stuff. I chose WORK:Java/ and permanently assigned a logical volume name Java: to it. If you don't know how to do this kind of thing, then you shouldn't be trying your had at any of this anyway. Sorry.

md WORK:Java
assign Java: WORK:Java
cd Java:
tar -xf kaffe-0.7.1-bin.tar
lha -x kaffe-0.7.1-sun-bin.lha

Now you need to setup a CLASSPATH environment variable. If you use a Java: assign like I do, then you can just type this:

copy console: env:CLASSPATH
Java:share/kaffe/classes.zip;.

and press ^ (EOF signal); notice that after the "...classes.zip" there is a semicolon followed by a dot. The semicolon is a separator between multiple paths (or .zip files) and the dot represents the current directory. This current directory is important, otherwise you cannot execute classes without placing them into a directory where they are visible (the current directory is not visible by default, that is what the dot does.)

I have also created two aliases in my s:Shell-Startup and added the Java:bin directory to my paths (you can do that in s:Shell-Startup or in your s:startup-sequence before the LoadWB to make the addition system wide.):

alias javac "Java:bin/kaffe sun.tools.javac.Main []"
alias java "Java:bin/kaffe []"

This now lets you type javac FunTest.java to compile the FunTest class in the FunTest.java file. Note that class names are case sensitive and must (exactly) match the file in which they're defined. This makes managment of many class files quite easy.

To run your compiled class, type java FunTest (without the .class extension)

Ok, my fingers are sore and I hope it's working...

Here a tiny little (and fairly banal) program just to see if you have everything working. After you've tried it out, go out and buy yourself a good Java book! I can happily recommend the following: Just Java, second edition, by Peter van der Linden; The Sunsoft Press, Java Series. The author has a great sense of humor and is quite aware of how Microsoft has been trying to fuck up the Java initiative. Great reading, great introduction to most all aspects of Java. 550 pages.

Store the following in a file named FunTest.java; the example after the aliases above will help you compile and run this file:


public class FunTest
{
    public static void main( String argv[] )
    {
        for( int i=0; i<argv.length; i++ )
        {
            System.out.println( "Argument #" + i + " = '" + argv[i] + "'" );
        }
        if( argv.length == 0 )
            System.out.println( "How about giving me a few command line " +
                                "arguments to print?" );
        else
            System.out.println( "Hey, wasn't that fun?" );
    }
}

If you have anything less than a fast 68030 or 68040 in your Amiga you will probably be disappointed by the performance. Compilation is quite slow (the compiler is itself an interpreted Java program) and execution is, of course, accomplished by interpreting the byte code.

The important thing is, however: Your Amiga can do Java. It just does not yet have a production-quality JVM. But for now, you'll do well to learn Java with what you've got: a free JVM for your Amiga: Kaffe!

About the Images
This page was created and is maintained by Udo K Schuermann; it has last been updated on Sunday August 03, 1997. If you find something amiss or you have comments, please email me.