jpackage: support for environment variables in --java-options
Michael Hall
mik3hall at gmail.com
Thu Sep 3 12:55:07 UTC 2020
> On Sep 3, 2020, at 7:12 AM, Scott Palmer <swpalmer at gmail.com> wrote:
>
>
>
>> On Sep 3, 2020, at 4:26 AM, Michael Hall <mik3hall at gmail.com <mailto:mik3hall at gmail.com>> wrote:
>>
>>
>>
>>> On Sep 2, 2020, at 10:07 PM, Scott Palmer <swpalmer at gmail.com <mailto:swpalmer at gmail.com>> wrote:
>>>
>>> There is already a way to supply a custom Info.plist.
>>> That can have the LSEnvironment entries you want.
>>>
>>> https://bugs.openjdk.java.net/browse/JDK-8233175 <https://bugs.openjdk.java.net/browse/JDK-8233175>
>>>
>>> I was under the impression that we were after something that would allow different values to get to the application based on environment variables. The env var values can’t be hard-coded in the Info.plist to do that, we want values that are expanded based on set environment variables on the user’s machine. Isn’t that what this is about?
>>>
>>> Scott
>>
>> Yes for Serban’s thread. Which was already shown not to work OS X on the users machine because user environment variables aren’t passed to applications.
>
> As I mentioned earlier, launchctl must be used to set environment variables that you want passed to GUI applications.
This is not how I’ve done it before. I did a little googling and it seemed to indicate launchctl could somehow be used for ‘global’ environment variables. It didn’t sound application specific. I have successfully done this on a application basis a couple times in the past as I mentioned earlier. Also from the old javafx JavaPackager I also mentioned earlier is this in Info.plist.vtl…
#if ($info.bundleJre)
<key>LSEnvironment</key>
<dict>
<key>JAVA_HOME</key>
<string>Contents/PlugIns/${info.jreDirectoryName}/Contents/Home</string>
#if($info.envPath)
<key>PATH</key>
<string>${info.envPath}</string>
#end
</dict>
The incident mentioned earlier showed a resolution of having the user provide their own custom Info.plist. While plain old edit would probably be fine for this some sort of code to provide it without manual intervention might also be nice. I believe I have some old code lying around that might just provide a beginning for such a thing.
More information about the core-libs-dev
mailing list