简体   繁体   English

调用在JDK中找到的JRE

[英]Invoke JRE that is found in JDK

I first installed JRE and Java applications ran fine. 我首先安装了JRE,并且Java应用程序运行良好。 Later on, I installed JDK and found out that JRE is part of JDK as sub-directory. 后来,我安装了JDK,发现JRE作为子目录属于JDK。 So, I removed the original JRE. 因此,我删除了原始的JRE。 This time, all the Java applications would not start. 这次,所有Java应用程序都无法启动。 JAVA_HOME is set correctly to point to the JDK (I am able to compile Java code). 正确设置JAVA_HOME使其指向JDK(我能够编译Java代码)。 The OS is Windows 10. Why is the JRE that is found in the JDK not getting invoked? 操作系统为Windows10。为什么未调用JDK中的JRE?

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. 当您安装JDK时,可以选择安装“ public JRE”-当您在命令行中键入java ...时,将调用独立于JDK在Windows中注册的单独安装,并将其添加到Windows注册表中java ...并将由仅依赖JRE / java可执行文件的程序使用。 The option to install "public JRE" is available in this step of JDK installation: 在JDK安装的此步骤中,可以使用安装“ public JRE”的选项:

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. 另一方面,JDK发行版中的jre文件夹是“私有JRE”-不会公开给所有Windows程序,也未在Windows注册表中注册。 If you install only the JDK without the "public JRE", java executable will not be found on the path. 如果仅安装不带“ public JRE”的JDK,则在路径中找不到java可执行文件。 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. 对于依赖于JAVA_HOME环境变量的程序,“私有JRE”将对程序有用,该环境变量应指向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). 我建议安装一个单独的“ public JRE”,但是如果您希望控制台中的java可执行文件可用,请将%JAVA_HOME%/jre/bin到Windows PATH (或仅将%JAVA_HOME%/bin添加到Windows中使用java可执行文件) JDK本身)。 See here for an instruction on how to modify your PATH variable. 有关如何修改PATH变量的说明,请参见此处 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 . 假定您已设置JAVA_HOME环境变量-如果尚未设置,则可以在修改PATH的相同配置窗口中进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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