Part of the web server. San Francisco CA USA. 7/29/96.

Java and Frontier Sittin' in a Tree!

How to call Java code from Frontier and vice versa...

by Doug Baron,

When something interesting shows up written in Java, you can now plug it into your Frontier systems and websites by following the logic in the HelloFrontier sample app. And you can fully control the Mac OS and scriptable apps from Java.

This package demonstrates how to create Apple Event-aware Java Applets using Sun's MacJDK 1.0.2. Other vendors' Java development environments may or may not support the classes I used.

You can download the package from:

The demo app illustrates how to both send and receive Apple Events. The code is based on Sun's HelloAWT example. Comments in the code highlight the AE additions.

How To Run

  1. HelloFrontier requires Sun's MacJDK 1.0.2.

  2. The HelloFrontier folder can be placed anywhere on your disk.

  3. Make sure that UserLand Frontier is running.

  4. Drag HelloFrontier.class onto the Applet Runner application.

  5. To send events to the Java app, run the statesLooper desktop script.

What happens

Frontier's main window displays a message in response to a Do Script event sent by the HelloFrontier applet.

HelloFrontier is ready to receive Apple Events. The event it understands is "Set Message". In UserTalk terms, here's the event:

appleEvent ("Applet Runner", 'aevt', 'smsg', '----', "Frontier and Java")

As you'd expect, the app's response to the event is to display the string in its window.

The door is open! Have fun. :)


Steve Zellers

Steve Zellers,, who now works on Java at Apple, helped us get this together. Steve adds:

Works fine here; the only thing I would caution is to not use the word "Applet" where the word "Application" should be. You aren't creating applets at all, and aren't covered by any security arrangements thereby.

Remember: applet is a secure piece of code running in a host environment, and usually restricted in what it can access on a client system. Applications are fully featured standalone applications that can do anything on a client system that you can do in "C". (Provided that the appropriate glue libraries are availiable.)

Think of "Java Runner" as the segment loader.

Thanks Steve!

This page was last built with Frontier on a Macintosh on Mon, Jul 29, 1996 at 11:40:46 AM. Thanks for checking it out! Dave