Skip to content

Optional Cache Directory

Bradley Turek edited this page Dec 19, 2018 · 6 revisions

The cache dir option will override the directory the downloaded artifacts are placed in. By default, artifacts are placed in the current working directory. The program parameter --cache-dir or the manifest entry cacheDir can be specified to override this.

This feature can be helpful in several circumstances:

  • If the application is installed in a placed where the user does not have write access
  • If there is a problem with configuring the current working directory, as seen with some Mac Java Version
  • To cache commonly used library files amongst several installed apps

The program parameter will override any configured value in the manifest, and the default will still be "the current working directory".

Install Once, Updates For All

If you install your app for the whole system (the default if using an MSI installer), the app will require admin privleges to install. After being installed, your natively installed app only contains the fxlauncher.jar; it still needs to download your app from the specified URI.

With the default cacheDir value, FXLoader will try to cache the downloaded artifacts where it was installed—in this case, that system-wide folder—the problem is that it takes admin privileges to put things in that system-wide folder. When launching, apps don't have enough privileges to put things in that system-wide folder (can: run; can't: write). To get around this problem, we still install the app system-wide, but then tell it to put any updates it downloads somewhere it has permission to put them.

There are at least two strategies and two magical strings that will place your app in the correct place based on the current OS.

USERLIB

For when you want each user to have their own cache of dependencies.

If the cache dir parameter starts with the magical string USERLIB/ this string will be replaced with an OS-specific path corresponding to the place where user-level applications are installed—no admin privileges required.

Consider the following parameter value:

--cache-dir=USERLIB/MyApp

The result will be:

| OS | Location | Comments | ------------- |-------------| | Windows | C:/Users/{SomeUserName}/AppData/MyApp | | Mac | ~/Library/Application Support/MyApp | | Linux | ~/.MyApp |

(for the unitiated the ~ symbol corresponds to the home directory on Mac/Unix systems)

ALLUSERS

For when you want the whole system to share a single cache of dependencies.

If the cache dir parameter starts with the magical string ALLUSERS/ this string will be replaced with an OS-specific path corresponding to the location where system-wide-accessible files can be placed and removed—no admin privileges required.

Consider the following parameter value:

--cache-dir=ALLUSERS/MyApp

The result will be:

OS Location Comments
Windows C:/ProgramData/MyApp Why the ProgramData folder?
Mac /Library/Application Support/MyApp
Linux /usr/local/share/MyApp
Clone this wiki locally