Java and the Amiga

Karl Jeacle

July 1996

CUGI Newsletter

Spring 1995 saw the launch of Sun Microsystems' new portable programming language, Java. It took some time before multi-platform support became available, and it established itself as a technology which could bring interactivity to the WWW. Over a year later, Java is still a buzzword in the computing magazines, and people are starting to realise that it has potential to do a lot more than just run "crapplets" on web pages.

In this article, I'll briefly discuss what Java is all about, and report on the status of Java on the Amiga, both for application development and for running Java applets and applications. Most importantly, I'll give lots of pointers to information available on the Internet to help you get started working with Java on your Amiga.

Java Overview

There is an incredible amount of hype surrounding Java. Once you wade through all this dross, however, you realise that while Java has great potential, it is really nothing more than a programming language.

There are a number of features which make it stand out from all the other languages out there, but probably the most important aspect of the language is Sun's push to make Java code as portable as possible. The idea is that Java code can be written and compiled on ANY machine (that has a Java compiler) and the resulting "executable" can be run on ANY machine (that has a Java runtime engine).

This is achieved by not compiling Java code into a native binary executable for a particular CPU architecture e.g. Intel x86 or Motorola 680x0, but into a "bytecode" for a "virtual machine". This machine can be thought of as a machine which has a Java CPU instead of an Intel or Motorola processor.

Because the world is not full of machines with Java CPUs, we need a piece of native software on our computers to emulate this imaginary Java CPU. This piece of software is called a Java runtime engine - it emulates a virtual machine running a Java CPU. When Java was launched, there was obviously no such thing as a Java computer, but now Sun are shipping real Java CPUs, so before long, many machines may have Java co-processors on board to handle Java code natively in addition to a conventional CPU for their existing applications.

The upshot of all of this is that, in theory at least, it shouldn't matter what kind of computer you have to run the latest greatest applications... as long as they are written in Java. Application developers should be free to develop code on any platform which can generate Java bytecodes, and this code should in turn run on any machine that has a Java runtime engine.

Getting back to the Amiga, this means that if we want the Amiga to be Java compatible, we need to have the two basic programs mentioned above i.e. the compiler and the runtime engine.

Compilers

At present, the only Java compiler available for the Amiga has come from Fred Fish's ADE (Amiga Development Environment) initiative. It's a port of the Unix program, guavac. The original guavac is part of the Free Software Foundation's GNU project which aims to provide programmers with high quality freely available software development tools.

Being a Unix port, and indeed in the style of most GNU tools, guavac is a purely command line driven program. There is no fancy frontend. You run it from a CLI prompt to tell it what Java files to compile.

Incidentally, if you're wondering what Java is like to program, it's very similar to C++. If you have already programmed in C++ or have C experience with a knowledge of object-oriented principles, then you should be able to pick up Java quite quickly.

Runtime Engines

Once again, the only runtime engine available at the moment is a Unix port, and it too comes via the ADE. It's called Kaffe and unfortunately is very basic on the Amiga. What a straight port of Kaffe to the Amiga allows is the interpretation of Java bytecodes. This works perfectly well as long as there is little or no I/O from the Java application!

Basically, the Kaffe runtime engine itself has been ported, so a virtual Java CPU is available for Amiga users, but the supporting Java libraries which provide us with graphics, networking, etc are not yet available.

This leaves us in the unfortunate position of being able to happily compile Java applications on the Amiga, but not able to run them! If you're inventive enough though, there is a solution, albeit a rather clumsy one.

The Amiga can emulate a Macintosh. The Mac has two free Java runtime engines available - one from Sun, and one from Apple. An Amiga running ShapeShifter can run both of these, and use them to preview code compiled with guavac on the Amiga.

What you'll need

Here's the bad news: Java is extremely resource hungry. I've been able to develop Java applets using the Guavac compiler and preview them using Sun's JDK via ShapeShifter. Even better, I've been able to have ShapeShifter running at the same time as the Guavac compiler, so all I have to do is flick screens and hit reload on the applet previewer after each compile on the Amiga side.

Unfortunately, I've found that my 40MHz 68040 needs about 36MB of FAST RAM to do this comfortably. After booting, my Amiga has used about 8MB; then ShapeShifter has 16MB to itself; which leaves 12MB free for Guavac development work. Of course, it's early days yet, and subsequent releases of all the software concerned will hopefully be smaller and run faster.

Remember that the current version of Guavac is a Unix port and is larger than the average Amiga program (the executable is over 1MB). And having to run ShapeShifter to preview applets is way over the top! When a native Amiga runtime engine appears, it is likely to be much smaller and require far fewer system resources.

Java Information

It's no surprise to discover that the best place to look for more information on Java is on the Internet, so below are some useful URLs which should tell you more about everything discussed in this article.

For updates on what's happening on the Amiga Java front, you might like to check out Niall Teasdale's Amiga Java Page. You can also go directly to the original guavac and Kaffe pages, however, Fred Fish's Ninemoons site is where you'll find the Amiga ports.

Amiga Java Page

http://www.sss.co.uk/~nt/hotjava.html

Guavac

http://http.cs.berkeley.edu/~engberg/guavac/

Kaffe

http://www.tjwassoc.demon.co.uk/kaffe/kaffe.htm

Ninemoons

http://www.ninemoons.com/products/ade.html

Explaining how to get ShapeShifter running on the Amiga would require an article in itself. For the Mac Java programs here you'll need at least a 68030 and System 7.5.x.

ShapeShifter

http://www.uni-mainz.de/~bauec002/SSMain.html

Sun Mac Java Development Kit (JDK)

ftp://ftp.javasoft.com/pub/JDK-1_0_2-MacOS.sea.hqx

Mac OS Runtime for Java (MRJ)

http://www.devtools.apple.com/mrj/

For more information on Java in general, check out Sun's own Javasoft site. It's got all the specifications and white papers and latest information on what's hot in the Java world. If you're looking for Java applications, or libraries of code to help you write Java applets, then Gamelan is for you.

Javasoft

http://www.javasoft.com/

Gamelan

http://www.gamelan.com/

Sunsoft Press has published a number of books on Java, and both "Just Java" and "Core Java" have received good reviews. There are, however, many many books on Java, and most are aimed at programmers. If you want more general information on Java, by all means go to your local bookstore, but you'd be far better off surfing the web for articles, press releases and product reviews. If you're thinking of buying a Java book, an invaluable guide to some of the books available is at: http://sunsite.unc.edu/javafaq/books.html

There are also a number of Java newsgroups on Usenet. If you already read Usenet news, then by all means, check them out. If you're not a Usenet junky, you may find yourself a little lost in the ongoing discussions.

The Future

It looks as though Java is here to stay for the foreseeable future. Sun want the language to be ubiquitous. Their range of Java chips allow everything from toasters to workstations to support or make use of Java in one form or another. Industry pundits claims that "network-centric" computing with "thin clients" is the future.

In the same way that a set-top box can be relatively dumb and sit on your TV, yet provide you with lots of functionality, they expect many offices to replace today's desktop PCs with scaled-down "thin client" PCs that make greater use of the network and supporting large scale server machines in the background to provide functionality.

If this is the future for hardware, then the future for software must be Castanet from Marimba Inc. In the same way Java hit it big 18 months ago, expect the same thing to happen with Marimba. It's going to be everywhere. It's too complicated to describe here, suffice to say that it uses Java to deliver on many of the original promises that the Java evangelists have been on about for the last while. Check it out for yourself: http://www.marimba.com/

From an Amiga point of view, we can only hope that Java support will appear in web browsers as soon as possible. The viability of an Amiga set-top box (such as VIScorp's ED) would be greatly strengthened by the presence of a robust Amiga Java runtime engine. It is likely that web browsers will be the first Amiga applications to make use of Java, but if Java continues the way its going right now, the advent of native Amiga Java support could breath new life into the machine. The number of applications available to Amiga users could literally double overnight.

Leading software companies such as Corel are releasing Java based versions of their their top applications. Java's portability means reduced development costs for them in maintaining separate PC and Macintosh ports. The advantage to Amiga owners is that this increased ease of portability could lead to many big name applications suddenly running on the Amiga.

This is all going take time. But that version of Adobe Photoshop for the Amiga you were hoping for may be more likely that you thought!

Conclusion

Java is still a buzzword in the computing industry. All the major platforms now have Java ports. Given the current state of affairs in the Amiga world, it's no surprise that an Amiga port isn't quite there yet, but at least a number of initiatives are underway.

For most Amiga owners, it's a case of just waiting patiently and hoping that it won't be long before proper Java support is readily available. For those of you with high-end Amigas, you can start getting your hands dirty by coding some basic applets, and learning what Java is all about.

Despite its recent troubles, it's amazing to think that the Amiga that this article has been written on and which has run the Java programs mentioned above, was bought back in 1992. That's over four years ago - a long time in the computer industry.

If nothing else, the Amiga is a survivor. I'm optimistic that in the not-too-distant future Amiga users will be actively developing and running Java applets and applications natively, no matter what kind of Amiga they own.