Should I use JAVA_HOME for OpenJDK's JDK or OpenJDK's JRE?

后端 未结 1 911
刺人心
刺人心 2021-01-23 23:37

In many recent situations, but right now I tried using a installer, that throws an error and says something along the lines of \"Java not installed\" even though the JAVA_HOME i

1条回答
  •  -上瘾入骨i
    2021-01-24 00:17

    Your actual question is unclear, but this looks like an X-Y problem. Your real problem is that you had problems installing NetBeans 8.2 (right?), but you are incorrectly jumping to the conclusion that the cause was somehow related to your setting of JAVA_HOME. It isn't.

    First, from the NetBeans 8.2 download page, note that "JDK 8 is required for installing and running the Java SE, Java EE and All NetBeans Bundles. NetBeans 8.2 does not run on JDK 9 or later". So at least part of your problem is that you were trying to use JDK 13 with NetBeans 8.2. That just won't work.

    Second, you don't need to set the environment variable JAVA_HOME for NetBeans 8.2 to work. I just deliberately sabotaged my setting of JAVA_HOME, and NetBeans 8.2 restarts and works just fine. This is a good thing, because you may legitimately want to set JAVA_HOME to some arbitrary JDK for some other reason completely unrelated to NetBeans, and doing so might break NetBeans 8.2 if it relied on JAVA_HOME.

    Third, NetBeans does not care about your PATH setting either. (As an aside, NetBeans ignoring JDK_HOME and PATH means that you can install different versions of NetBeans each of which uses a different JDK, and safely run them concurrently.)

    To explicitly specify the JDK that your NetBeans 8.2 installation should use:

    • Locate the file netbeans.conf. It is a text file and resides in the etc directory under your NetBeans 8.2 installation.
    • Open that file in any text editor, and locate the line containing the text netbeans_jdkhome.
    • If the line starts with a # (denoting a commented line) remove that, then set netbeans_jdkhome to specify the path to your JDK 8 installation. On my Windows 10 machine that line looks like this: netbeans_jdkhome="C:\Java\jdk1.8.0_221".
    • Ensure that you have exactly one uncommented line setting a value to netbeans_jdkhome (which will be to your JDK 8 installation directory), then save your changes to netbeans.conf and (re)start NetBeans 8.2.

    Hopefully that is all you need to do to resolve your issue, but if not please update your question to clarify the precise problem that needs to be solved.

    0 讨论(0)
提交回复
热议问题