jpackage: support for environment variables in --java-options

Andy Herrick andy.herrick at oracle.com
Wed Sep 2 14:04:09 UTC 2020


Yes - environment variables are not a good answer for this, not just 
mac, but even on windows the env variables at run time are different if 
launched from a shell (the env variables of that shell) vs. when run 
from a shortcut (the system-wide or user env variables set in Control 
Panel or Settings dialog).

JEP-343 says jpackage should be "a tool for packaging self-contained 
Java applications.", so an app packaged with jpackage should run on a 
machine without requiring any other files to be installed .  That should 
not prohibit optional configuration from being discovered on a machine 
and used to tune the application or it's use of Java.

Normally, any such discovery can be done by the application itself, 
except where it is the the java options that tune the java vm itself, 
and that is why we are considering mechanisms (such as expanding 
environment variables at runtime, or reading an installed configuration 
file of some kind)

/Andy


On 9/1/2020 7:08 PM, Michael Hall wrote:
>
>
>>
>> On macOS you need to set the variables differently, but I think it 
>> can still work. The variables known to your shell are not the same as 
>> those known to LaunchServices. For those use the launchctl command to 
>> set them.
>>
>
> I’m not that familiar with launchctl. Is this something the 
> application user is expected to do? What experience I have had with 
> applications and environment variables involved adding the entries to 
> Info.plist. Making the environment variables normally available to the 
> application as environment variables.
>
> My question is if there is or will be any kind of OS X support for 
> this in jpackage? LSEnvironment settings in the Info.plist file.
>
> e.g. the following was what was recently mentioned on the javafx list…
> https://github.com/fvarrui/JavaPackager 
> <https://urldefense.com/v3/__https://github.com/fvarrui/JavaPackager__;!!GqivPVa7Brio!O4AJBY7WHrDUAAitry0YRGzPuObDA7YGraA3H26Zedp4l2Y8vywHCyqXgHGomDYF1w$>
> envPath
>
> Defines PATH environment variable in GNU/Linux and Mac OS X startup 
> scripts.
>
>
> Otherwise, this seems to be getting a little confusing, for me anyhow, 
> as to what you’re trying to do and when. Are you trying to use 
> environment variables at build time to replace variables that will be 
> resolved in the config file. Which seemed to be what Serban was 
> asking. Or did I misunderstand that and Serban actually wants settings 
> that will be resolved at application launch?
> Or do you want to use them at application launch time as some kind of 
> mechanism to override config file settings there like jdk memory 
> settings? Which seems to what the jdk issue concerned.
>
> My question seems simpler. I will let others resolve other environment 
> variable usage at build or launch time. I am interested in runtime.
>


More information about the core-libs-dev mailing list