Question

I have created an executable java Swing .jar application. It works fine on Windows. The application hierarchy is :

application.jar

images(Folder) .......... Contains all images the application uses.

libraries(Folder) ....... Contains all external jar libraries the application uses.

bundles(Folder) ......... Contains all bundle files the application uses.

database(Folder) ........ Contains the database files the application uses.

All the above folders exist outside the jar file. Now i am trying to create a Mac executable file (.app) from "application.jar" to run it on Mac so i used the "Jar Bundler" as specified here but when i run the output application.app file nothing happens, nothing runs and i can't even debug it.

I think the main reason is that it can't see the external folders. So is it impossible to create a .app file if the application has external folders ? And is there a way to debug the .app file to see what's going on ?

Was it helpful?

Solution

Most likely the problem is your working directory.

  • When you run an executable JAR file by double-clicking it, the working directory is the parent directory of the JAR file.

  • By default, the working directory of an application bundle is its parent directory. If you package the external folders into the application bundle they will be located under $APP_PACKAGE/Contents/Resources.

So the assumption about the working directory that you make for an executable JAR file does not hold for an application bundle.

In order to set the working directory to the resources directory, add

<key>WorkingDirectory</key>
<string>$APP_PACKAGE/Contents/Resources</string>

to the Info.plist file of your bundle.

In case you know nothing about application bundles, please read this document.

OTHER TIPS

Nothing runs, and i can't even debug it.

Diagnostic output from the launch process may be obtained as follows:

$ export JAVA_LAUNCHER_VERBOSE
$ ./YourApplication.app/Contents/MacOS/JavaApplicationStub

There's a related example here.

This might help: AppBundler by Josh Marinacci

I am not sure about your exact directory hierarchy. But on a Mac with Xcode installed is an application called "Jar Bundler". It exist for exact that purpose you are asking for. BTW, Mac application use the suffix .app, that is right. But they are not files. Thery are directories.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top