oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Running Java Applications on Mac OS X
Pages: 1, 2

Comment on this articleIf we had a double-clickable app for Jini tools, Mac could be the platform of choice for Jini development. Is there any work underway in this area?
Post your comments

If you click on the green button, there can be a redrawing problem with the larger window that is corrected if you do a live resize by grabbing the lower-right corner. There's more, however, to the Mac experience than just being able to use the genie effect while shrinking JUnit down to the dock. In the next section, we'll look at making the user experience more Mac-like.

Creating a double-clickable version

You don't want a user to have to navigate to the right directory and type in the class path every time they run JUnit. One of the cool things Apple did in shipping Mac OS X was to ship the developer tools along with the operating system. We'll use MRJAppBuilder to quickly package JUnit up as a double-clickable app. You'll find MRJAppBuilder in the /Developer/Applications/ directory. Start it up and let's start filling in the various fields in the Application tab pane.


In our first shot, let's fill in the fields with the same values we used from the command line. There the main class name was junit.swingui.TestRunner and the class path was [Install Dir]/junit3.7/junit.jar:. . This class path is interesting because it uses one absolution path and one relative path. The "." assumes that we're inside of the [Install Dir]/junit3.7 directory, so we're forced to put our output file there. We could change the "." to an absolute path and place the output file anywhere. For now, we choose the clever name for our output file and set the fully qualified name as [Install Dir]/junit3.7/

This is fine if you are just creating a quick application that will sit on your own machine. If you use absolute paths, you can move anywhere on your machine. On the other hand, if you are interested in using this technique to deploy applications to other users, you should use relative paths. This way your application is not dependent on the directory structure of the user's machine. In our case, we can change the class path to junit.jar:., and choose "Build Application".

You'll notice that we didn't enter the name of the test suite being run. To add a parameter, select the Java Properties tag. You'll see that you can add properties to be set and modify many of the ones that you see. If you'd like, add the parameter junit.samples.AllTests and rebuild your application. In this case, we won't notice a real difference, but with other applications this will be useful.

Screen shots.

The first community challenge: Jini

Perhaps the hardest thing about working with Jini is getting all of the pieces working on your machine. There are many sites that are devoted to long descriptions of the steps involved in getting rmid, a web server, Reggie, Mahalo, and Outrigger up and running.

Our first community challenge is to use the discussion forums on this page to come up with a very simple solution for running Jini on Mac OS X. You can find out more about Jini at, and in Jini section of the Sun Microsystems web site. You can start up Jini with a GUI tool that comes with the distribution. To do this, just load the file you will find in .../jini1_1/example/launcher/.

Daniel H. Steinberg is the editor for the new series of Mac Developer titles for the Pragmatic Programmers. He writes feature articles for Apple's ADC web site and is a regular contributor to Mac Devcenter. He has presented at Apple's Worldwide Developer Conference, MacWorld, MacHack and other Mac developer conferences.

Read more Java Programming on the Mac columns.

Return to the Mac DevCenter.