Artiom
Artiom

Reputation: 21

Java application installer for MacOS

I'm new at Java for Mac developement and I spent a lot of time finding a way how to create an installer. It's strange but it's not too much information about it. All the ways lead to using of JavaAppLauncher. (I use appbundler-1.0.jar and Ant to build .app) But I faced a following problem.

JavaAppLauncher sets working directory to user folder. My application consists of several jar files, resources and configuration files. All of them located in Contents/Java inside the .app structure. I use relative paths to them, relative to the executable jar with Main class.

I googled 2 discussions only, where someone asked how to set the working directory inside the .app bundle. Threre is a way to sed -Duser.dir JVM option in plist file of .app bundle. I tried this and it behaves strange. When I use "new File(".").getAbsolutePath()" - it shows the directory I pointed in -Duser.dir parameter, but when I try to create file on disk or read file from disk - it still goes to the user folder as it was by default.

May be someone knows what is wrong there? Or is there any better way to create a java application bundle for Mac? Thank you, guys.

Upvotes: 2

Views: 475

Answers (1)

Aniruddha Sarkar
Aniruddha Sarkar

Reputation: 1923

Use JarSplice to create OS X app bundle. Compile all your jars and resources into one jar file and export as mac .app file.

JarSplice

Deploying Java Applications can be a pain if your application has multiple jars and native libraries. There are the options of using Java Web Start or Java Applets however these are not always suitable. Executable Jars are an option, however if your project has multiple jars or native files then it can be tricky to use this option. JarSplice attempts to solve this issue by allowing you to merge all your jars and native files into one, easy to use executable jar file.

Features:

Creates a single executable fat jar via an easy to use GUI. Automatically extracts only the native files needed for the OS the jar is running on. Automatically cleans up any extracted native files after the application quits. Add VM arguments on jar creation which removes the need to enter them via the command line. Optionally create a Shell Script (.sh) launcher for Linux with embedded fat jar. Optionally create an OS X App Bundle (.app) for running your application. Optionally create a Windows Application (*.exe) for running your application.

This is the best cross-platform installer creator i have found yet. You can get the java executable from here

Upvotes: 2

Related Questions