You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "sid-srini (via GitHub)" <gi...@apache.org> on 2026/06/03 14:57:54 UTC

[PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

sid-srini opened a new pull request, #9425:
URL: https://github.com/apache/netbeans/pull/9425

   - 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 fix brings parity with unix (PR #8725) and windows (PR #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_home` tool no longer supports a suffix '+' in the version string to indicate a minimum supported version, and only uses the `--version` 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) as the default.
       - 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.
   
   
   
   
   
   ---
   **^Add meaningful description above**
   
   <details open>
   <summary>Click to collapse/expand PR instructions</summary>
   
   By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
   
    - are all your own work, and you have the right to contribute them.
    - are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).
   
   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:
   
   1. [ ] Was this PR [correctly labeled](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=240884239#PRsandYouAreviewerGuide-PRtriggeredCIJobs(conditionalCIpipeline)), did the right tests run? When did they run?
   2. [ ] Is this PR [squashed](https://cwiki.apache.org/confluence/display/NETBEANS/git%3A+squash+and+merge)?
   3. [ ] Are author name / email address correct? Are [co-authors](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line) correctly listed? Do the commit messages need updates?
   3. [ ] Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?
   
   If this PR targets the delivery branch: [don't merge](https://cwiki.apache.org/confluence/display/NETBEANS/Pull+requests+for+delivery). ([full wiki article](https://cwiki.apache.org/confluence/display/NETBEANS/PRs+and+You+-+A+reviewer+Guide))
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

Posted by "sid-srini (via GitHub)" <gi...@apache.org>.
sid-srini commented on PR #9425:
URL: https://github.com/apache/netbeans/pull/9425#issuecomment-4620437346

   > Yes, that's fair enough - keep as a separate issue for further thought. The IDE distributions with JDK for Linux do actually set `JAVA_HOME` to the same as `jdkhome` if it's not already set. I added that because it's quite useful when using the terminal in the IDE. I just realised the macOS launcher doesn't while considering how it interacts with your change.
   
   Understood. I agree that setting `JAVA_HOME` to `jdkhome` *when* it is not already set, seems like a good improvement without much of a down-side. I'll create a separate PR later, including all the 3 platforms for this. 
   Thanks @neilcsmith-net.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #9425:
URL: https://github.com/apache/netbeans/pull/9425#issuecomment-4615009927

   Thanks, looks good to me!
   
   > 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.
   
   Yes, that's fair enough - keep as a separate issue for further thought.   The IDE distributions with JDK for Linux do actually set `JAVA_HOME` to the same as `jdkhome` if it's not already set.  I added that because it's quite useful when using the terminal in the IDE.  I just realised the macOS launcher doesn't while considering how it interacts with your change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien merged PR #9425:
URL: https://github.com/apache/netbeans/pull/9425


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

Posted by "sid-srini (via GitHub)" <gi...@apache.org>.
sid-srini commented on PR #9425:
URL: https://github.com/apache/netbeans/pull/9425#issuecomment-4614893260

   Thanks a lot @neilcsmith-net for your review and suggestions. I've incorporated the feedback on lifting the `JAVA_HOME` check outside the OS-specific block, as well as, making it take precedence over sdkman.
   
   I have not exported `JAVA_HOME` with the value set for `jdkhome` mainly so that the change may be made uniformly for windows and *nixes in a separate PR, depending on overall consensus.
   
   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #9425:
URL: https://github.com/apache/netbeans/pull/9425#discussion_r3349698834


##########
platform/o.n.bootstrap/launcher/unix/nbexec:
##########
@@ -154,21 +154,37 @@ if [ -z "$jdkhome" ] ; then
         # try to find JDK
         case "`uname`" in
             Darwin*)
-            # check if JAVA_HOME is empty string since java_home will return the value of JAVA_HOME
-            if [ -z "$JAVA_HOME" ]; then
-                unset JAVA_HOME
-            fi
-            # read Java Preferences
-            if [ -x "/usr/libexec/java_home" ]; then
-                jdkhome=`/usr/libexec/java_home --version 1.8+`
-            # JDK1.8 as a fallback
-            elif [ -f "/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java" ] ; then
-                jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home"
-            fi
-
-            # JRE fallback
-            if [ ! -x "${jdkhome}/bin/java" -a -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" ] ; then
-                jdkhome="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
+            # check if JAVA_HOME is empty string
+            if [ ! -z "$JAVA_HOME" ]; then
+                jdkhome="${JAVA_HOME}"

Review 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"?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Enhance platform launcher to honour JAVA_HOME on macos [netbeans]

Posted by "sid-srini (via GitHub)" <gi...@apache.org>.
sid-srini commented on PR #9425:
URL: https://github.com/apache/netbeans/pull/9425#issuecomment-4620796624

   I've squashed the commits after review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists