11
  • NOTE: The question is not about the difference between JDK and JRE.

Oh, I am sorry. The question is not discuss about JDK and JRE. But I cannot express clearly in my title. So I try to explain in here.

I want to know the difference between two folders!

C:\Program Files\Java\jdk1.8.0_161\jre and C:\Program Files\Java\jre1.8.0_161

Describe in details:

I am new to JAVA. I have installed the JDK in my Windows 10. When I install jdk, there were two steps. After double click jdk-8u161-windows-x64.exe, two steps as follows:

  1. Step 1: install jdk. (In C:\Program Files\Java\jdk1.8.0_161)

  2. Step 2: install jre. (In C:\Program Files\Java\jre1.8.0_161)

But when I open the jdk1.8.0_161 folder. I can also find a jre folder.

Could anyone tell me the difference between C:\Program Files\Java\jdk1.8.0_161\jre and C:\Program Files\Java\jre1.8.0_161?

If they are the same, why is jre installed in the installation process of jdk ? Are they duplicated?
In other world, is Step 2 needless?

JosanSun
  • 339
  • 2
  • 12
  • 3
    the jre in the jdk folder is part of the jdk. You can have a jre without a jdk, but you can't have a jdk without a jre – Stultuske Jan 22 '18 at 06:57
  • 2
    Good question :P I have asked myself similar question but have never tried to find the reason out :P What I can tell is , for development purpose, that "standalone" JRE is useless. I have never had that in my path and all my dev tools runs well. I suspect it may have something to do with the OS integration, like let the Java control panel or browser looking up usable JRE. – Adrian Shum Jan 22 '18 at 07:09
  • 1
    check this https://stackoverflow.com/questions/1906445/what-is-the-difference-between-jdk-and-jre – Peter Haddad Jan 22 '18 at 08:41
  • @PeterHaddad oh! pls read my question carefully. Thanks. Your answer is not I wanted. – JosanSun Jan 22 '18 at 08:56
  • Possible duplicate of [What is the difference between JDK and JRE?](https://stackoverflow.com/questions/1906445/what-is-the-difference-between-jdk-and-jre) – xxxvodnikxxx Jan 22 '18 at 11:08
  • I guess, you just installed JRE separately, and then also JDK... So it created both directories. I guess you will be able to reconfigure IDE to use "standalone" JRE, but maybe some things from JDK will be not working- you will need to reconfigure it also, but it will be messy... Maybe it has something to do with JVM- standalone can be pure for run, and "internal" for JDK using. – xxxvodnikxxx Jan 22 '18 at 11:11
  • @xxxvodnikxxx it is better to read SubOptimal's answer. He knows what I want. – JosanSun Jan 22 '18 at 13:35
  • @JosanSun oh, you are correct, but [there is also the answer] (https://stackoverflow.com/a/1906455/4892907) But the answer bellow is more clear – xxxvodnikxxx Jan 22 '18 at 15:35

1 Answers1

6

The JRE within the JDK C:\Program Files\Java\jdk1.8.0_161\jre (also referenced as private JRE) is used by the JDK tools. The JRE outside C:\Program Files\Java\jre1.8.0_161 (also referenced as the public JRE) should is meant to be used by the Java applications.

private JRE

  • contains the library (attach.dll) needed for the use of the attach API
  • will be uninstalled with the JDK

public JRE

  • registers the Java Plug-in and the java web start in the browsers
  • this JRE is registered in the system, e.g. as runtime for Java applications, the Java control panel
  • can be uninstalled separately from JDK
SubOptimal
  • 22,518
  • 3
  • 53
  • 69
  • 1
    “should be used by the Java applications” is a bit strong. You may run applications using the JRE embedded in the JDK (I never used anything else) without problems and some applications even required a JDK. Also, the JDK isn’t polluted with crapware like the stand-alone JRE (was; I didn’t recheck whether it still is). In the past, there was the problem that the public JRE was required to be installed in the boot partition on Windows. In the future, this distinction is supposed to die entirely. The Java 9 JDK doesn’t have a “jre” folder… – Holger Jan 22 '18 at 10:52
  • @Holger I agree with you. The JREs are identically (except the attach related stuff). But it's better to use outside development only the JRE which is registered in the system. If you mix the both you might searching for errors on the wrong place. Anybody who knows about the difference is free to do whatever fits best for him. The point about the bundled additional software in the JRE installer I cannot comment. As you I always use the JDK (not because of the bundled software, rather for the JDK part ;-) ). – SubOptimal Jan 22 '18 at 11:43
  • @SubOptimal I am happy. Thank you for understanding my question. You give what I want. I surly don't want to know the difference between `JDK` and `JRE`. – JosanSun Jan 22 '18 at 13:32