The Kopi Java Compiler Suite

Release Name: Rel 1.1

Notes:
This is the Kopi java compiler package -- an "everything you need" for the development of java programs onboard the Zaurus; that is, everything that you need outside of the built in Intent java virtual machine and a good editor or the Qtopia text editor or vi. Here is the enclosed and updated/corrected Readme.txt:

Hey, I've packaged up here an open source GPL'd java compiler named Kopi together with the necessary "classes" file (this one from the author of the guavac java compiler) to make, together with an editor and the Insignia Jeode system on board the Z, the smallest java development system you are likely to find anywhere. And it works pretty well, and is particularly good for java beginner noodling and small java projects of the sort that you might want to enter on the Z's keyboard, and compile and run right on the PDA.

Installation:

Move the kjc-suite.jar and the gclasses.zip file over to the Zaurus by any means, and put them either on a flash card or on the ram disk, at, say /home/root. For example, I use the Z's ftp server (at port 4242) to put these files on my compact flash card at /mnt/cf. The Kopi.htm file could go too -- it describes the Kopi tools and how to envoke them and you can view it with the Opera browser on the Z.

Compiling a java program:

You can now create a java program with your favorite onboard editor -- the Qt text editor will do. For example:

class Hello{
  public static void main(String[] args){
    System.out.println("Hello Dogface!");
  }
}

Then compile the program from the terminal app like this (all on one line, the prompt is already there):

bash-2.05# evm -cp /mnt/cf/kjc-suite.jar at.dms.kjc.Main -C/mnt/cf/gclasses.zip Hello.java

If it compiles without error, a new file, "Hello.class" will have been created, and you can then execute your new program with:

bash-2.05# evm Hello

and get the message that you've been waiting for all this time.

Caveats:

Well, a few things are missing and there are some minor problems with this solution, to wit:

1) You will not be able to compile a very large program in a single file this way -- there just isn't enough free memory on the Z. The limit is unknown, but I have had trouble at about 150k (with ROM 1.02). This is not usually a problem since if you typed 150k on the Z's keyboard, you would already be dead.

2) The class file is a "stubbed" file -- it only has in it the bare necessities and does not look at all like the thing you get from Sun in the jkd1.1.8 classes.zip file. So sometimes you can't compile something someone wrote long ago -- but that is the usual story with Java, despite the hype. I have run in to the occational missing constant. (Actually I have discovered that Kopi agrees with Jikes, the compiler from IBM, and that the javac compiler takes liberties.)

3) If you want the classes (timer stuff, mainly) that is in that part of personal java not in java 1.1.8, then you will have to get the pj.jar file from the appropriate place and presumably change the compiler argument from "-C/mnt/cf/gclasses.zip" to "-C/mnt/cf/gclasses.zip:/mnt/cf/pj.jar" or some such.

4) The compiler does not agree with Sun on everything in the java language -- for example, it thinks the 'default' clause should be after all 'case' clauses in the 'switch' statement. It will barf sometimes, but usually you will not think to fool it so.

Credits:

Well, the Kopi group has done a great job. Look for their site on the web. There is another fellow maintaining a separate compiler thread called Kopisusu, but I haven't tried it.

The gclasses file is from the guavac java compiler -- also on the web. There are other, similar, class files around. They solve the problem of the Sun file being 9 MB or so, and I can't stand that. There is one connected with the Kaffee project; and I guess I could make one the hard way, but this will do, and I thank he who made it. (But see below for other possibilities.)

Good luck java programmers!

Jeffrey R. Fox
JeffreyRFox@msn.com
distribution #2
12/10/03

P.S. A shell program ('jcc') to launch the compiler might contain the single line:

evm -cp /mnt/cf/kjc-suite.jar at.dms.jkc.Main -C/mnt/cf/gclasses.zip $@

Then

bash-2.05# . jcc Hello.java

compiles.

Using either Jikes or Kopi requires a "class library" in order to resolve references to the insignia Personal Java classes onboard the Zaurus. I have found no way to use the onboard core.jar and awt.jar file for this purpose. The simple and smallest solution is the included gclasses.zip. But another solution is to get the class library "rt.jar" from Sun's jre1.1.8 (i. e., the "java runtime environment 1.1.8" distribution package). I can't pack this for you without violating Sun's license, but all you have to do is go to:

http://java.sun.com/products/jdk/1.1/jre/download-jre-windows.html

and download the jre (we use 1.1.8 because that most closely matches the support on the Zaurus). (You could download the Solaris jre if you are using Linux on your PC.) Install it on your PC -- you only need one file ("rt.jar") -- ditch the rest 'cause it's way out of date.

More Notes: Using the real deal -- Sun's javac

You can also compile directly with Sun's javac on the Z, though jikes is both much faster (~10 times) and a little smaller (4.3 MB verses 4.8 MB for the minimal package). (Kopi is much smaller.) To use javac, you will need to download and install (on your PC) Sun's jdk1.1.8 development package, and then move the classes.zip file (and nothing else, unless you want to try the examples) from the lib directory to the Zaurus. To compile using javac, use:

evm -cp /mnt/cf/classes.zip sun.tools.javac.Main yourapp.java

This classes.zip file is almost 9 MB but it can be compressed -- do this with WinZip or with the JAR utility in the jdk (read the JAR doc) on your desktop before moving it to the Zaurus. The result is about 4.8 MB, and it works the same way.

Speaking of JAR, the classes.zip file has the functionality of JAR too (that is, of zip and unzip):

evm -cp /mnt/cf/classes.zip sun.tools.jar.Main 

and there are other development tools in there too.

So now you know almost everything I have discovered so far. Kopi will work with rt.jar too, and that makes a little bit better compiler than it is with the enclosed, stubbed, classes.zip from the guavac distribution, but as packaged it works about as well as it is going to, which is fine for all but the most demanding of usage. Jikes seems to be the most memory efficient, but is too picky to be used with the stubbed classes.zip from guavac.