Rebuilding the MacBinary Toolkit 2 for Java

Last revised: 17Feb2003 GLG

Table of Contents

General Notes

The platform-neutral Java source needs no special handling. You can recompile it on any platform compliant with JDK 1.1 or later. The only platform-specific source is in the specific implementations.

The implementation of:
    glguerin.io.imp.gen.GenericForker
need to be compiled against the included MRJToolkitStubs.jar file. This imp also needs to be distributed with MRJToolkitStubs.jar, either bound into the same JAR as the implementation, or otherwise available in the class-path. The implementations of PlainForker and JavaOnlyForker in the same package are completely platform-neutral.

The Mac OS implementations in the package tree:
    glguerin.imp.mac.*
need additional special handling outlined below. Since these implementations are Mac-specific, and won't ever be loaded on non-Mac platforms, you don't have to bundle additional classes with them. Either the classes they reference will be present in MRJ on Mac OS, or the implementations will never be loaded, so it doesn't matter what other classes they reference.

Recompiling the Mac OS Implementations

The Mac OS implementations must be compiled against classes that are only available under Mac OS. Most of these classes are distributed as part of the normal MRJ installer, or are present in a default install of Mac OS X. A small number of classes that are not provided with every MRJ have been included with the MacBinary Toolkit distribution.

You should normally only compile against classes from MRJ 2.2 or higher. Older versions of MRJ may or may not work -- I have only tested compiling against MRJ 2.2.

Each Mac OS implementation is compiled against one or more ZIP or JAR files. Special considerations are outlined for each implementation.

Packaging for Redistribution

The GenericForker implementation is compiled against MRJToolkitStubs.jar. You must also include this ZIP in your executable redistribution, or the generic imps will fail with a "Class not found" error. The easiest thing to do is simply merge MRJToolkitStubs.jar into your redistribution's JAR file. Another option is to include it as an additional component of the classpath, though this is needlessly complex from a user's perspective.

DO NOT redistribute the MBXCarbonCore.jar classes with any executable-only redistribution. They are only intended for recompiling the Mac OS X imp, and will only make your executable redistribution pointlessly larger than it needs to be.

The MacOSXForker and CarbonMacOSXForker imps have a separate JNI-library file that contains the native code. This library-file should be placed in Contents/Resources/Java within an app-bundle, or in the same place the JAR is placed in a Java extensions location. Basically, wherever you put the JAR, put the JNI-library there, too.

Rebuilding the Demo Apps

The classical Mac OS apps were created using JBindery from the MRJ SDK. The creator-IDs are 'MBcx' for Converter, 'MBsx' for Spy. (I have not officially registered these creator ID's with Apple yet.) Be sure to include the relevant resource-file from the "Resources for droplets" folder when you rebuild the apps.

You can also rebuild the classical Mac OS apps using MRJAppBuilder from the MRJ SDK. I have included the configuration properties files to do this in the "Resources for droplets" folder. These properties files are configured to build a merged application. That means you must add an appropriate JAR-file to MRJAppBuilder's "Files to merge" list, along with the appropriate "Resources-XXX.rsrc" file.

I chose to distribute the classical Mac OS apps as JBindery-built apps, rather than as apps built by MRJAppBuilder. This is mainly because JBindery-built apps will work on older versions of MRJ, as far back as MRJ 2.0. Apps built by MRJAppBuilder, on the other hand, will only work under MRJ 2.2 or higher. This would prevent the apps from working on older platforms, such as 68040 machines under MRJ 2.0, and I didn't want to do that.

The Mac OS X apps were originally created using MRJAppBuilder on Mac OS X, a tool that's included with the Mac OS X Developer Tools. Thereafter, I edited the configuration files using the Mac OS X tools "Property List Editor" for the Info.plist, and "TextEdit" for the MRJApp.properties file. "Property List Editor" is in Apple's Developer Tools install. Double-clicking Info.plist launches the right program, but you have to drag-n-drop MRJApp.properties onto TextEdit. If you understand XML, you can edit Info.plist with TextEdit, or with your XML editor of choice. To gain access to the files bundled into the app itself, contextual-click on the application and choose the "Show Package Contents" contextual-menu item to see the internal anatomy of the app-bundle.


To Greg's Home Page
To Greg's Software Page