The Java jlink utility allows you to make a customized (minimized) runtime for a self-contained project. The resulting file structure could simply be zipped and shipped. But before doing so, applying the following hack will make the project much easier to use.
The executable for a jlinked project is a bash script embedded in its /bin subfolder.
-
Move the bash script to the top folder.
-
Open the script with TextEdit and edit it as follows:
Change the start of the last line from "$DIR/java " to "$DIR/bin/java " -
Rename (if needed) the bash script to the name that you wish to give the application.
-
Rename the top folder to the same exact name as the bash script (case sensitive), but with “.app” extension added.
-
When the MacOS system asks to verify that you wish to make this change, say yes.
At this point you will have converted the top-most file folder holding your application and resources into a manually constructed Bundle that will appear to the MacOS as a single-file .app, without having gone through the complications of conforming to the Bundle file structure or having to provide an Info.plist configuration file.
-
Open the “Get Info” for the .app.
-
If you have your own icon for the project, drag the .icns file over the existing default icon in the top left corner of the “Get Info” and drop. The .app file should now display your icon.
The resulting .app file can be zipped and shipped, but the following steps may also be helpful:
-
Create a new folder and place the .app file in this folder.
-
Create a ReadMe.txt file and add it to this top folder.
-
Zip and ship the folder holding the .app and the ReadMe.txt files.
MacOS downloads arrive in the /Downloads folder. From there, the user can drag the .app to wherever they wish. But with a ReadMe, you can provide useful information such as suggestions for where to install, version info, and instructions for using the application.
Also, the ReadMe.txt can provide info on how to first run the program. This can be helpful if the user is unsure of how to run a program that has not been obtained from the App Store, and thus is blocked by a “safety” warning.