Often when developing an application for AIR 2.0 we realize that for whatever reason we simply can’t accomplish the task at hand without involving another language such as Java. There are several reasons why this might be the case, the fact that AIR 2.0 doesn’t work with non-storage USB devices such as a MIDI piano, another might be the use of Java multi-threaded capabilities for time sensitive operations that won’t bog down your UI. For developers looking to easily integrate the 2 languages, Transmission holds the key for quick and effective communication between AIR and Java using AMF.
One pitfall I came across a few months ago dealt with the fact that Java applications always show up on the Mac dock, even while using Transmission. This is problematic because starting up an AIR application which starts up Java shows 2 applications running on the Mac dock. This might be confusing for users, plus it gives them the opportunity to kill the Java application which inhibits your AIR application from taking advantage of Java. To resolve this issue I have provided a fix. On the Windows side, you don’t need to worry. Java will only show itself in the windows toolbar if UI code is present. Otherwise it will be hidden by default.
The process to do this on a Mac is to wrap your application’s jars in a Mac OS X application. To do this, we need to use a Utility called Jar Bundler. This should be found here: /Developer/Applications/Utilities or you can pull it up in Spotlight. When you open the application, you should see a screen like this:
Here are the steps you’ll need to take in order to get an application:
1. Click on Choose next to the Main Class option. Next, navigate to Transmission.jar that came with the transmission project and select it. It should populate the Main Class field with transmission.Transmission automatically.
2. Under arguments type: -transmissionControllerPackage transmission.demo.TransmissionDemoController. For your own project replace the TransmissionDemoController package with your own TransmissionController’s package and class name (make sure your own TransmissionController implements ITransmissionController).
3. Select the Classpath and Files tab and choose all other jars that belong to your project besides the Transmission jar you added in step 1.
4. Choose some properties in the Properties tab.
5. Click Create Application and choose a destination for the new application.
Bam! Your application is completed. Now we need to make sure it hides itself when it is run. Right click on your application and choose “Show package contents”. Navigate to Contents and open the Info.plist file. This file contains the preferences you set in the Jar Bundler. To make the application hide we need to add a couple more. Before the Java item, add the following rows
1. LSUIElement (in the value column enter “1″)
2. NSUIElement (in the value column enter “1″)
Your plist should now look something like this: 
The last thing we need to do is configure the application inside of your Flex Transmission configuration. In your Flex project, rather than doing Transmission.init() using the Java executable, the TransmissionController package, and the array of classpaths, simply do the following:
1 | Transmission.getInstance().init("path/to/app/DemoApplication.app/Contents/MacOS/JavaApplicationStub"); |
Now everything should work!
Enjoy!
