Enhance platform launcher to honour JAVA_HOME on macos#9425
Conversation
neilcsmith-net
left a comment
There was a problem hiding this comment.
Thanks for looking at this. It's a good change, although I think the now identical check for JAVA_HOME should be extracted from the case statements, and ideally take precedence.
I still think this should also set the value of JAVA_HOME to match whatever jdkhome gets set to.
Will need to be tested with the NBPackage Swift launcher, but should be OK.
| # check if JAVA_HOME is empty string | ||
| if [ ! -z "$JAVA_HOME" ]; then | ||
| jdkhome="${JAVA_HOME}" |
There was a problem hiding this comment.
I would be tempted to move this statement before the check for sdkman, and remove from inside both case options, which would also allow removing an if/else level. I think JAVA_HOME should take precedence over sdkman, but could go after it if others disagree. Also can remove the comment, or change to "use JAVA_HOME if set"?
|
Thanks a lot @neilcsmith-net for your review and suggestions. I've incorporated the feedback on lifting the I have not exported Personally, I am not entirely convinced if the launcher should change the value of a well-known env var, not specific to the NetBeans platform, for subsequent usage from the IDE. For example, it may cause a mismatch in the user's expectations on their code run from the IDE vs. a terminal. This may be even more stark with the IDE distribution which contains a (private) jdkhome bundled within itself. |
|
Thanks, looks good to me!
Yes, that's fair enough - keep as a separate issue for further thought. The IDE distributions with JDK for Linux do actually set |
Understood. I agree that setting |
- The nbexec platform launcher, used by ide launcher (netbeans) and
the harness launcher (app.sh), even on macos, should honour JAVA_HOME
and PATH-based JDKs when jdkhome is unspecified.
- This brings parity with unix (PR 8725) and windows (PR 8408) for the
nbexec launcher's behaviour on MacOS.
- Made JAVA_HOME take precedence over sdkman.
- Thanks neilcsmith-net for this suggestion
- Additionally, since netbeans is no longer supported on JDK 8, the
Apple-specific options targeting JDK 8 as a fallback are removed.
- Finally, the Apple /usr/libexec/java_home tool no longer supports a
suffix '+' in the version string to indicate a minimum supported
version, and only uses the filter as an exact match.
- Thus, the version argument has been dropped.
- The current behaviour of the tool is to return the latest version
jvm available in /Library/Java/JavaVirtualMachines/ (or similar
Apple-specific locations only).
- The PATH based fallback is left as the last one since the
java_home tool provides the correctly resolved JDK home instead of
the Apple java launcher utilities, /usr/bin/javac and
/usr/bin/java, which are expected to always be on the PATH.
6702063 to
1bc174c
Compare
|
I've squashed the commits after review. |
The nbexec platform launcher, used by ide launcher (netbeans) and the harness launcher (app.sh), even on macos, should honour
JAVA_HOMEandPATH-based JDKs whenjdkhomeis unspecified.This fix brings parity with unix (PR Honor the JAVA_HOME environment variable in nbexec script #8725) and windows (PR Enhance launcher #8408) for the nbexec launcher's behaviour on MacOS.
Additionally, since netbeans is no longer supported on JDK 8, the Apple-specific options targeting JDK 8 as a fallback are removed.
Finally, the Apple
/usr/libexec/java_hometool no longer supports a suffix '+' in the version string to indicate a minimum supported version, and only uses the--versionfilter as an exact match.--versionargument has been dropped./Library/Java/JavaVirtualMachines/(or similar Apple-specific locations only) as the default.PATHbased fallback is left as the last one since thejava_hometool provides the correctly resolved JDK home instead of the Apple java launcher utilities,/usr/bin/javacand/usr/bin/java, which are expected to always be on the PATH.^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)