简体   繁体   中英

Invoke JRE that is found in JDK

I first installed JRE and Java applications ran fine. Later on, I installed JDK and found out that JRE is part of JDK as sub-directory. So, I removed the original JRE. This time, all the Java applications would not start. JAVA_HOME is set correctly to point to the JDK (I am able to compile Java code). The OS is Windows 10. Why is the JRE that is found in the JDK not getting invoked?

When you are installing JDK, you have an option to install "public JRE" - a separate installation that will be registered in Windows independently from JDK, added to the Windows registry, will be invoked when you type java ... in the command line and will be used by the programs relying just on JRE / java executable. The option to install "public JRE" is available in this step of JDK installation:

JDK安装

On the other hand, the jre folder inside the JDK distribution is a "private JRE" - not exposed to all your Windows programs, not registered in the Windows registry. If you install only the JDK without the "public JRE", java executable will not be found on the path. The "private JRE" will be useful for the programs depending on the JAVA_HOME environment variable, which should be pointing to the root of the JDK.

I recommend installing a separate "public JRE", but if you want the java executable to be available in the console, add %JAVA_HOME%/jre/bin to your Windows PATH (or just %JAVA_HOME%/bin to use the java executable from the JDK itself). See here for an instruction on how to modify your PATH variable. That assumes you have set the JAVA_HOME environment variable - if you haven't, you can do it in the same configuration windows where you modify your PATH .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM