I am trying to implement multi-channels (deb/beta/stable) update for my app following recommendation made in another SO post.
I have done the following steps:
mediaID=${compiler:sys.mediaId}
mediaID = Variables.getCompilerVariable("mediaID"); Variables.saveToPreferenceStore(Map.of("updatesUrl", xmlURL), mediaID, true);
ApplicationLauncher.launchApplicationInProcess(UPDATER_APPLICATION_ID, null, ....)
but this throws an error (exit value = 1):Based on the error message, it seems that the updater does not find the updatesUrl
variable but just before the call to the function I logged the output of com.install4j.api.launcher.Variables.loadFromPreferenceStore(mediaID, true);
and I got as a result {updatesUrl=https://github.com/akasolace/HO/releases/download/dev/updatesDEV.xml}
which is the legit URL, so it seems updatesUrl was properly stored.
Now, I am a bit confused on how this should work. Me for example, I am running 2 version of the app in parralel and my setup is something like:
on my system I will have variable updatesUrl
store in 2 differents package something like:
{(1, "updatesUrl"): "...updatesSTABLE.xml", (2, "updatesUrl"): "...updatesDEV.xml"}
Now, in install4J, I added the action "Load installer variable from the Java preference store" and I see package name default to ${compiler:sys.applicationId
. This leads to the following question:
[Edit] I tried to set package name of "Load installer variable from the Java preference store" to ${compiler:sys.mediaId
but this throws instead
Thank you in advance for your help.
with the following stack trace
java.lang.NullPointerException
com.install4j.runtime.installer.Application.runApplicationInProcess(Application.java:64)
com.install4j.runtime.installer.helper.apiimpl.ApplicationLauncherImpl$1.run(ApplicationLauncherImpl.java:57)
Calling com.install4j.api.launcher.Variables.loadFromPreferenceStore
does not set installer variables, it returns a map with the variable values. This is intended for use in your application.
What you have to do is to add a "Load installer variables from the Java preference store" action to the "Startup" node in in the update downloader. In that way, the updatesUrl
installer variable is actually set to the value from the preference store.