3

I have a SWT based Java application that works on Windows, Mac OS and Linux. I develop it on my Windows machine and have a tester with Linux and a tester with a Mac. Currently my process creates a runnable .jar file for each platform on my Windows machine (which references the platform specific .jar and lib files from Eclipse.org). I have a working installer for Windows - also produced by the build on the windows machine. I want to create a standard Mac OS installer for my Mac users. The right way to do that appears to be to create a .app bundle and distribute it via a dmg file. This has not being going well. I have a working Java app that uses SWT and can be run from the command line, on all platforms. I have a way of building a .dmg on Windows. But so far all my attempts to get a .app bundle to work have failed.

I started by following this tutorial: http://www.eclipse.org/swt/macosx/

But when running my application I get an error saying that applications for the Power PC are not supported. That is using the same binaries that work from the command line using java -jar so the problem must be in the the way I am bundling. The sample Hello app from the page also fails to work but with a different error message.

I have been searching all day and found this promising talk: http://www.parleys.com/#st=5&id=2891&sl=72

In that talk the speaker says there will be a way to create a Mac OS .app bundle on any platform using a standard java launcher. But I cannot find any such thing released yet.

I found this post that also looks promising: http://www.intransitione.com/blog/take-java-to-app-store/

But this recipe says it will not work except by building on a Mac OS machine.

What I want to do is create a .app bundle for Mac OS X on my windows machine along with the Windows install and the Linux install. It would be preferable to also include a jre as part of the app bundle (which I already have working for Windows and Linux). I hope someone can point me in the right direction.

Ian Leslie
  • 841
  • 1
  • 9
  • 25

1 Answers1

4

Have you seen this?

The .app is just a directory with a special structure a few special files. Once you have it created, you'll only need to update the JAR each time you build, which can be found here: MyApp.app/Contents/Resources/Java/MyJar.jar.

There will also be a few Java-specific properties in My.app/Contents/Info.plist, but you probably won't need to change these from how you initially set them up.

martinez314
  • 12,162
  • 5
  • 36
  • 63
  • 1
    Yes, I know and getting that template set of special files and java specific properties is what is eluding me. The links to examples I looked at do *not* work. I am hoping someone can point me in the right direction. – Ian Leslie Nov 30 '12 at 21:44
  • @IanLeslie Apple used to have an app called JarBundler which you could use to package your Java executable, but they have discontinued it. I believe the link I posted is Oracle's replacement solution to create the .app. – martinez314 Nov 30 '12 at 21:48
  • Thanks @whiskeyspider. I have successfully build a Swing app as a bundle and am now working on my SWT app. – Ian Leslie Dec 05 '12 at 03:44
  • Thanks for the Jar Bundler tip @whiskeyspider. I went to spotlight and searched for "jarbundler" and found a folder with that name. Inside is a tool that asked me for the jar file and an icon and then created the bundle. The hardest part was converting a png into icns. – newz2000 Aug 23 '13 at 19:15