Open fjtorres opened 6 years ago
FXLauncher is packaged with javapackager
and can do everything javapackager
can do, but nothing more either. All the supported configuration options are listed in the documentation:
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javapackager.html
The "magical" string USERLIB
is translated to different locations based on OS. We could surely add something similar for ALLUSERS
if we can find platform equivalent options. Maybe you'd like to supply a PR? It's pretty easy, have a look at how USERLIB
is implemented:
if (cacheDir.contains("USERLIB")) {
String replacement;
switch (OS.current) {
case mac:
replacement = Paths.get(System.getProperty("user.home"))
.resolve("Library")
.resolve("Application Support")
.resolve(cacheDir.substring(8))
.toString();
break;
case win:
replacement = Paths.get(System.getProperty("user.home"))
.resolve("AppData")
.resolve("Local")
.resolve(cacheDir.substring(8))
.toString();
break;
default:
replacement = Paths.get(System.getProperty("user.home"))
.resolve("." + cacheDir.substring(8))
.toString();
}
path = Paths.get(replacement);
} else {
path = Paths.get(cacheDir);
}
Alternatively, if you'd research corresponding locations for the different platforms, I could do the implementation.
Looking at the implementation above I see that it's a bit naive - it requires USERLIB
to be first in the path. This can easily be fixed though.
Thanks @edvin, I searched a lot about javapackager
but I didn't find anything about uninstall process so it's not possible to define uninstall directories. Also if I use the same folder of the application as cache directory the downloaded files are not deleted in uninstall process.
For now I supposed that the javapackager
is not able to customise the uninstall process but seems strange behaviour because Inno-Setup
is used to build the setup file.
About the ALLUSERSPROFILE
environment variable on Windows, I never found a direct mapping to OSX or UNIX system. In this case for my current JavaFX application I used this approach:
switch (ESystem.getSystem()) {
case WINDOWS:
appDataDir = Paths.get(System.getenv("ALLUSERSPROFILE"));
break;
case MAC:
appDataDir = Paths.get(System.getProperty("user.home"), "Library", "Application Support");
break;
case UNIX:
appDataDir = Paths.get(System.getProperty("user.home"));
break;
}
However I didn't do test about this because right now all the users have Windows OS.
Something that may be of use here is the AppDirs library https://github.com/harawata/appdirs. While the locations of user lib directories do vary by OS, and are basically arbitrary, this library at least provides a single entry point to retrieving the directory you want.
@zemudkram Great!, the use of this library could be the solution. However the use of external libraries to do it made the jar a bit bigger but could be very useful to have more options to install the application in different directories.
There is no need to include a library, as long as the paths are known it should be fairly simple to add the functionality directly to this project. Anybody want to submit a PR?
I created the pull request #113 with specific folders for all users. Could you review that?
Perfect, thanks! Merged now :)
I added some documentation of the ALLUSERS
option in the README (pending merging of PR #145) and the wiki.
Hello,
I am trying to migrate my current auto-update system to FXLauncher but I have some stuff that I am not sure if it's possible to configure with FXLauncher. Currently I am using Launch4j and InnoSetup to build the application installer and executable file.
I need to install the application for all the users of the system, How can I configure the cache dir for this topic? I am using ALLUSERSPROFILE environment variable in windows system to allow this in my current configuration. Does FXLauncher support for this?
Another topic is the uninstall process, my application generate some files/folders inside ALLUSERSPROFILE/MyApp folder and I delete it with my custom InnoSetup configuration. Does FXLauncher support to configure something for that? I was searching for javapackager but I didn't find anything.