Search code examples
javamacosjarbundler

Installing and Running Java application on Macs


I have a java desktop application for which I am trying to create a Mac application package. The application is composed of two runnable jar files and several folders of text and images. The first jar acts as an updater and launcher for the second jar which is the bulk of the application. The application uses a variety of data files and images that are referenced in the application by relative path name (e.g. ./images/bits/xyz.jpg).

On Macs, however, I am having trouble getting the relative pathnames to work after creating a Application Bundle with Jar Bundler. I have no personal experience with Macs and need help understanding the standard way to laying out an application on them. I have noticed that other applications that I have installed come as a disk image file that opens with instructions to drag the app into the applications folder. I am trying to create a similar install package. Thank you in advance for your advice.


Solution

  • Drag and drop instruction in a disk image is a complete red herring. Once the app bundle is correctly made, it does not matter whether it's in the disk image or it's just zipped.

    Note that on Macs, executables (whether native Cocoa or Java) don't have its current directory set to the path of the executable. So, you first need to get the current absolute path of the jar file, say. For that, there are already Q&As on Stack Overflow. See e.g. here.