macosjavapackager

Add folder to bundle when build mac installer using javapackager


I have JavaFx ShowTime.jar and config folder. To run the software, the config folder needs to be in a same directory as ShowTime.jar. In side the config folder, there are two folders : preferences and plugins.

I can bundle the config folder with the jar using the following codes:

javapackager -deploy -native dmg -name ShowTime -BappVersion=1.0.0 -Bicon=ShowTime.icns -srcdir . -srcfiles config -srcfiles ShowTime.jar -appclass ShowTime -outdir out -v

If user install the software first time, copy jar and config folder to installation directory. This is achieved.

When user install new release, I want to replace the plugins folder but keep the existing preferences folder. I dont know how to do this?

Many thanks.


Solution

  • That's not how applications normally work. Modifiable configuration items are normally held in a separate user-specific folder. The name and location of this folder is in general different for each OS but a relatively common approach is to place an invisible folder inside the home directory of the user. Something like ".MyApplication" for example. This folder and its initial content has to be created by your software when the application is started for the first time. When a new version of the software is installed you may keep this folder because it is not overwritten by the installer.