Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Cannot set JAVA_HOME via LSEnvironment #111

Open
1 task done
kiwicodemonkey opened this issue Mar 24, 2021 · 9 comments
Open
1 task done

Cannot set JAVA_HOME via LSEnvironment #111

kiwicodemonkey opened this issue Mar 24, 2021 · 9 comments

Comments

@kiwicodemonkey
Copy link

I'm submitting a…

  • bug report

Short description of the issue/suggestion:

Setting JAVA_HOME via the LSEnvironment key in Info.plist is not recognised when running universalJavaApplicationStub.

Steps to reproduce the issue/enhancement:

  1. Add following to plist:
		<key>LSEnvironment</key>
		<dict>
			<key>JAVA_HOME</key>
			<string>Contents/Plugins/zulu-8.jre/Contents/Home</string>
		</dict>

  1. Run app

What is the expected behavior?

Application launches and runs

What is the current behavior?

Script complains that no java environment is found.

Please tell us about your environment:

  • universalJavaApplicationStub version: 3.2.0
  • macOS version: Big Sur 11.2.3 (M1)
  • Java version(s): zulu8.52.0.23-ca-jre8.0.282-macosx_aarch64

Other information:

If I edit the script and set JAVA_HOME, the application launches and runs fine.

@tofi86
Copy link
Owner

tofi86 commented Apr 15, 2021

Sorry for my delayed response.

Can you open the Console.app (not Terminal!) and set a filter/search for syslog and then launch your app. You will find a bunch of log messages from the stub in the Console.app window. Please select all and copy them here so I can assist you any further...

@kiwicodemonkey
Copy link
Author

kiwicodemonkey commented Apr 15, 2021

default	10:12:51.512291+1200	syslog	[79710][universalJavaApplicationStub] [StubDir] /Applications/MyAppM1/MyApp9.app/Contents/MacOS
default	10:12:51.563175+1200	syslog	[79710][MyAppPackage] [PlistStyle] Oracle
default	10:12:51.675458+1200	syslog	[79710][MyAppPackage] [JavaRequirement] JVM minimum version: 1.8+
default	10:12:51.689277+1200	syslog	[79710][MyAppPackage] [JavaRequirement] JVM maximum version:
default	10:12:51.718013+1200	syslog	[79710][MyAppPackage] [LanguageSearch] Checking preferred languages in macOS System Preferences...
default	10:12:51.756067+1200	syslog	[79710][MyAppPackage] [LanguageSearch] ... found [en-AU]
default	10:12:51.769931+1200	syslog	[79710][MyAppPackage] [LanguageSearch] ... selected 'en-AU' ('en') as the default language for the launcher stub
default	10:12:51.783813+1200	syslog	[79710][MyAppPackage] [Language] en
default	10:12:51.824675+1200	syslog	[79710][MyAppPackage] [JavaSearch] Checking for $JAVA_HOME ...
default	10:12:51.838397+1200	syslog	[79710][MyAppPackage] [JavaSearch] ... haven't found JAVA_HOME
default	10:12:51.852890+1200	syslog	[79710][MyAppPackage] [JavaSearch] Searching for JavaVirtualMachines on the system ...
default	10:12:51.923681+1200	syslog	[79710][MyAppPackage] [JavaSearch] ... found JVM: :/bin/java
default	10:12:51.936255+1200	syslog	[79710][MyAppPackage] [JavaSearch] Filtering the result list for JVMs matching the min/max version requirement ...
default	10:12:52.017436+1200	syslog	[79710][MyAppPackage] [JavaCommand] ''
default	10:12:52.044425+1200	syslog	[79710][MyAppPackage] [JavaVersion]
default	10:12:52.071192+1200	syslog	[79710][MyAppPackage] [EXIT 3] No suitable Java version found on your system!
This program requires Java  8 or later.

@tofi86
Copy link
Owner

tofi86 commented Apr 23, 2021

Unfortunately, I'm not able to reproduce the issue. This is my output with a test app:

standard	18:04:57.177411+0200	syslog	[20304][Test] [JavaSearch] Checking for $JAVA_HOME ...
standard	18:04:57.185931+0200	syslog	[20304][Test] [JavaSearch] ... found JAVA_HOME with value Contents/Plugins/zulu-8.jre/Contents/Home
standard	18:04:57.193769+0200	syslog	[20304][Test] [JavaSearch] ... parsing JAVA_HOME as relative path inside the App bundle to the executable '/Users/tofi/Desktop/test2.app/Contents/Plugins/zulu-8.jre/Contents/Home/bin/java'
standard	18:04:57.846864+0200	syslog	[20304][Test] [JavaCommand] '/Users/tofi/Desktop/test2.app/Contents/Plugins/zulu-8.jre/Contents/Home/bin/java'
standard	18:04:58.014223+0200	syslog	[20304][Test] [JavaVersion] 1.8.0_292 / 08000292
standard	18:04:58.028548+0200	syslog	[20304][Test] [WorkingDirectory] /Users/tofi/Desktop

My system:

  • universalJavaApplicationStub: 3.2.0
  • macOS 11.2.2 (Intel)

I cannot test on an M1 though, but I'm pretty confident this doesn't relate to the processor architecture.

Are you sure you're really using universalJavaApplicationStub v3.2.0? There have been issues with Big Sur support in earlier versions which resulted in the console output you pasted here (especially found JVM: :/bin/java) which are resolved in 3.2.0 (refs #100).

Although it doesn't relate to the original problem (that Apple's App framework obviously does not export the JAVA_HOME variable), can you please share the output of the following command with me, so I can debug the afore mentioned issue regarding the found JVM: :/bin/java log entry:

/usr/libexec/java_home --xml

@tofi86
Copy link
Owner

tofi86 commented Apr 23, 2021

FYI: If you edited the Info.plist file manually and just start the app again with a double click from the finder, in some situations the App cache serves an old version of the app. You can try to come over this by renaming the app folder or incrementing the app version in Info.plist.

@karokhaziz
Copy link

I have same issue please how can i solve this

@tofi86
Copy link
Owner

tofi86 commented Aug 30, 2021

@karokhaziz as I wrote above: In this certain case I wasn't able to reproduce the issue and setting JAVA_HOME via the LSEnvironment key worked for me in the exact way @kiwicodemonkey wrote in its initial posting.

Is your log output the same as @kiwicodemonkey's?

default	10:12:51.824675+1200	syslog	[79710][MyAppPackage] [JavaSearch] Checking for $JAVA_HOME ...
default	10:12:51.838397+1200	syslog	[79710][MyAppPackage] [JavaSearch] ... haven't found JAVA_HOME

@karokhaziz
Copy link

@karokhaziz as I wrote above: In this certain case I wasn't able to reproduce the issue and setting JAVA_HOME via the LSEnvironment key worked for me in the exact way @kiwicodemonkey wrote in its initial posting.

Is your log output the same as @kiwicodemonkey's?

default	10:12:51.824675+1200	syslog	[79710][MyAppPackage] [JavaSearch] Checking for $JAVA_HOME ...
default	10:12:51.838397+1200	syslog	[79710][MyAppPackage] [JavaSearch] ... haven't found JAVA_HOME

yes i have the same out put in the console haven't fount JAVA_HOME
i am using intel mac

@karokhaziz
Copy link

karokhaziz commented Sep 11, 2021

@karokhaziz as I wrote above: In this certain case I wasn't able to reproduce the issue and setting JAVA_HOME via the LSEnvironment key worked for me in the exact way @kiwicodemonkey wrote in its initial posting.

Is your log output the same as @kiwicodemonkey's?

default	10:12:51.824675+1200	syslog	[79710][MyAppPackage] [JavaSearch] Checking for $JAVA_HOME ...
default	10:12:51.838397+1200	syslog	[79710][MyAppPackage] [JavaSearch] ... haven't found JAVA_HOME

when I double click on universalJavaApplicationStub it work fine but when i double click on the icon app its not working i don't know why
thanks for your help

@tofi86
Copy link
Owner

tofi86 commented Nov 2, 2021

when I double click on universalJavaApplicationStub it work fine but when i double click on the icon app its not working i don't know why

That's most likely a cache issue, as I wrote above:

FYI: If you edited the Info.plist file manually and just start the app again with a double click from the finder, in some situations the App cache serves an old version of the app. You can try to come over this by renaming the app folder or incrementing the app version in Info.plist.

Or you can copy the app to another directory and rename it. This should also start the app with a clean cache...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants