Oracle JDK installs two JREs?

南楼画角 提交于 2019-12-06 03:31:18

问题


Before downvoting or close-requesting this question please see that this question is about JDK 7 not 6, it has a second question 'Q2' which is not addressed by any duplicate thread and this question is about four not only two java.exe instances. Thank you!


I've just installed Oracle's Java SE JDK (64 bit) which resulted in the following directory layout, and somehow two JREs:

C:\Program Files\Java\
    \jdk1.7.0_40
        \jre
    \jre7

I'm now the proud owner of four java.exe executables:

C:\Program Files\Java\jdk1.7.0_40\bin\java.exe
C:\Program Files\Java\jdk1.7.0_40\jre\bin\java.exe
C:\Program Files\Java\jre7\bin\java.exe
C:\Windows\System32\java.exe

Q1: Which one should I put into my search path to execute Java-based applications?

Q2: Do I need to put the Unlimited JCE Policy files just into the security sub-directory of the corresponding JRE in my search path or also into all others in order to work correctly?


回答1:


While installing JDK you will have a copy of JRE installed automatically. You need not install a copy of JRE separately. yet this will be your directory structure.

The copy of JRE in the JDK folder is for the is a private copy of JRE.

Installing the JDK installs a private Java SE Runtime Environment (JRE) and optionally a public copy. The private JRE is required to run the tools included with the JDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\jdk1.6.0\jre) whose location is known only to the JDK. On the other hand, the public JRE can be used by other Java applications, is contained outside the JDK (typically at C:\Program Files\Java\jre1.6.0), is registered with the Windows registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be removed using Add/Remove Programs, might or might not be registered with browsers, and might or might not have java.exe copied to the Windows system directory (making it the default system Java platform or not)."




回答2:


Which one should I put into my search path to execute Java-based applications?

According to the "JDK and JRE File Structure" document, you should add jdk1.7.0\bin to the path:

c:\jdk1.7.0\bin Executable files for the development tools contained in the Java Development Kit. The PATH environment variable should contain an entry for this directory. For more information on the tools, see the JDK Tools.


Do I need to put the Unlimited JCE Policy files just into the security sub-directory of the corresponding JRE in my search path or also into all others in order to work correctly?

According to the "Unlimited Strength Java(TM) Cryptography Extension Policy Files" documentation you will need to install the unlimited strength policy JAR files for all JREs that you plan to use.:

On Windows, for each JDK installation, there may be additional JREs installed under the "Program Files" directory. Please make sure that you install the unlimited strength policy JAR files for all JREs that you plan to use.



来源:https://stackoverflow.com/questions/18896541/oracle-jdk-installs-two-jres

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!