How to call Java code from Frontier and vice versa...
By Doug Baron, email@example.com
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
- HelloFrontier requires Sun's MacJDK 1.0.2.
- The HelloFrontier folder can be placed anywhere on your disk.
- Make sure that UserLand Frontier is running.
- Drag HelloFrontier.class onto the Applet Runner application.
- To send events to the Java app, run the statesLooper desktop script.
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, firstname.lastname@example.org, 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.
© Copyright 1996-97 UserLand Software. This page was last built on 5/7/97; 1:39:12 PM.
It was originally posted on 7/8/96; 3:51:44 PM.
Internet service provided by Conxion.