Skip to content

Correctly find and use OpenJDK #8336

Closed as not planned
Closed as not planned

Description

@i-make-robots

Description

Running netbeans-25 for the first time.
Popup tells me to install java >=17 or use command line --jdkhome.
Run netbeans64.exe --jdkhome C:\users\me.jdks\openjdk22.0.2
Quit and run again. Doesn't remember the JDK I used.

Expected behavior:

  1. find default installs of openjdk
  2. remember alt jdks supplied by user. 2a) at least remember one if there are no others available.

Workaround:
Edit the netbeans shortcut to include the --jdkhome param. Forget all about it until the next openJDK update causes confusion/frustration.

Context:
I have installed:
c:\program files\java\jdk-13
c:\program files\java\jdk-15
c:\program files\java\jdk-15.0.1
c:\program files\java\jdk-15.0.2
c:\program files\java\jre1.8.0_441
c:\users\me.jdks\openjdk-21
c:\users\me.jdks\openjdk-21.0.1
c:\users\me.jdks\openjdk-21.0.2
c:\users\me.jdks\openjdk-22
c:\users\me.jdks\openjdk-22.0.1
c:\users\me.jdks\openjdk-21.0.2

I will be removing most of these. Just odd Netbeans couldn't find a single one over 17.

Use case/motivation

No response

Related issues

No response

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:feature
    needs:triage
    on Mar 14, 2025
  2. mbien commented on Mar 15, 2025

    @mbien
    Member

    Run netbeans64.exe --jdkhome C:\users\me.jdks\openjdk22.0.2
    Quit and run again. Doesn't remember the JDK I used.

    this isn't how it is supposed to work. netbeans --jdkhome C:\users\me.jdks\openjdk22.0.2 is passed as regular program argument. Those do not persist.

    take a look at etc/netbeans.conf and scroll down. The netbeans_jdkhome property is what you are looking for. Creating a shortcut which would pass the arguments would work too.

  3. neilcsmith-net commented on Mar 15, 2025

    @neilcsmith-net
    Member

    To be fair, expected behaviour 1) is a known issue in the launcher. Although if you're using the (now legacy) installer, that has probably set a no longer valid value in conf already, so would override any fix elsewhere. Agreed 2) is not how it's supposed to work though.

    The better shortcut workaround is perhaps to use --jdkhome "%JAVA_HOME%\" Note the additional backslash because Windows in its wisdom combines path delimiter and escape character! 😄

  4. mbien commented on Mar 15, 2025

    @mbien
    Member

    yeah the windows launcher is a bit out of date and is known to not look at the right registry entries/paths in some situations. It is currently relying on something, e.g an installer or the user to edit the conf or the program args.

    I was referring to

    Running netbeans-25 for the first time.
    Popup tells me to install java >=17 or use command line --jdkhome.
    Run netbeans64.exe --jdkhome C:\users\me.jdks\openjdk22.0.2
    Quit and run again. Doesn't remember the JDK I used.

    Program args override the config, they don't modify configuration files.

    e.g they allow you to run two instances at the same time without having to adjust files:

    netbeans --userdir /tmp/tmpusr1
    
    netbeans --userdir /tmp/tmpusr2
    
  5. neilcsmith-net commented on Mar 15, 2025

    @neilcsmith-net
    Member

    I should have left the first paragraph out! 😄

    The point I wanted to make was that shortcuts can use environment variables, so the reporter's workaround can be done once assuming the JDK installations are setting up JAVA_HOME.

  6. mbien commented on Apr 9, 2025

    @mbien
    Member

    #8408 will let the windows launcher handle PATH / JAVA_HOME env vars better.

    So depending how you install the JDK, it should be picked up in future. Example: temurin installer will register the JDK in PATH by default (unless you change install settings).

    NB will not scan your drive to try to find JDKs though, it takes that information from the program arguments, config file, environment variables or windows registry (in roughly that order).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:featureneeds:triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions