frondoc picture

What is Frontier?
Download
News & Updates

Web Tutorial
Scripting Tutorial
BBEdit Scripting
Directory

Mailing Lists
Sample Scripts
Verb Set
Frontier Site Outline

Search
Guestbook
BBS

User's Guide
1 2 3 4 5 6
7 8 9 10 11

Apple File Edit
Main Open Suites
Web Window

Menubar Outline
Script Table WP

frondoc picture

Java and Frontier Sittin' in a Tree!

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

By Doug Baron, dougb@chilehead.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:

ftp://ftp.scripting.com/userland/javaFrontier.sit.hqx

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. :)

Doug

Steve Zellers

Steve Zellers, zellers@apple.com, 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!


© 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.