Sorry if these is very silly question bcz im new to java. JDK internally contains JRE then what is the need of JRE if it is a standalone application.
-
One word: production – Sep 04 '17 at 16:59
-
Perhaps you need to expand your question as it seems to be getting misunderstood. I suspect what you mean is why does the JDK installation include a separate JRE installation, when the JDK bin directory already contains a JRE? Correct me if that's not what you meant. I assume you already know why some people choose to install the JRE but not the JDK. – DodgyCodeException Sep 04 '17 at 17:03
-
1Because normal end users don't need the JDK, only the JRE. – Carcigenicate Sep 04 '17 at 17:03
-
1The reason for the JRE in the JDK is that many SDK tools are Java programs and you need a JVM (JRE) to run them. – PeterMmm Sep 04 '17 at 17:11
-
1Exactly why does the JDK installation include a separate JRE installation, when the JDK bin directory already contains a JRE? is my question and addind to this i have developed a simple java standalone application and working fine if there is both JDK and JRE in the class path, if i remove JRE it is not working even though JDK internally contains JRE and i'm running on the machine also. – John Sep 04 '17 at 17:14
-
2`if i remove JRE it is not working`, probably because the uninstall strips the path to the binary from the `PATH` environment variable. Uninstall all Java and only install JDK and it should work. – PeterMmm Sep 04 '17 at 17:17
-
ok so does JRE which is in JDK not involve in running our applications?. – John Sep 04 '17 at 17:19
-
@PeterMmm exactly. If you only install the JDK, you can run your Java applications. So why do we often *also* install the separate JRE product when installing the JDK? – DodgyCodeException Sep 04 '17 at 17:20
-
Ok thank you for your advise and most impotently patience. – John Sep 04 '17 at 17:21
-
@DodgyCodeException the reason is (AFAIK) the Java browser applet plugin, that is only in the JRE. – PeterMmm Sep 04 '17 at 17:42
-
THIS IS NOT a duplicate – Kalpesh Soni Apr 23 '18 at 16:54
1 Answers
Not everyone wants to build Java applications (this is JDK for). Many just want to run them (this is JRE for), e.g. the end users who get the JAR files.
For example: in my country, the electric tax filing is done via Java applications. Users need the JRE to run the program (where they can fill and submit the form), but not the whole JDK.
EDIT: According to OP's comments, the real question is why JDK contains an additional JRE. I made some research and found Oracle's explanation:
Private Versus Public JRE
Installing the JDK also installs a private 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.7.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.7.0), is registered with the Windows registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be removed using Add/Remove Programs, might be registered with browsers, and might have the java.exe file copied to the Windows system directory (which would make it the default system Java platform).

- 5,693
- 8
- 33
- 47
-
yes sir definitely agree with you but just say i only developed a standalone application and i only want to use then these case only JDK is sufficient ? – John Sep 04 '17 at 17:03
-
-
The JDK installation asks you if you want to also install the JRE (the default being yes). However, even if you say no, there is a JRE inside the JDK bin directory anyway, and you can still run your Java applications even though you didn't actually install the JRE. What then is the use of installing the JRE together with the JDK? (I think that's what the OP wants to know?) – DodgyCodeException Sep 04 '17 at 17:06
-
Maybe there is a convention (outside developer tools) that JRE should be in a ".../jre_VERSION/" directory. – juzraai Sep 04 '17 at 17:08
-
But you are asked during installation where to install the JRE and it doesn't have to be in a jre_VERSION/ directory. So it's not because of some convention. – DodgyCodeException Sep 04 '17 at 17:09
-
No. Providing an input field where user can customize the directory does not mean there is no convention. It just adds an option to alter from convention. IDEs can find the JDK/JRE automatically, right? And how do they find it? By **knowing the conventional path.** But what if they don't find it? They ask the user too. – juzraai Sep 04 '17 at 17:13
-
IDEs on Windows find the JDK/JRE by looking in the Windows Registry. Thus they can find it no matter what you've called it. On Linux, they usually find it through a symlink. – DodgyCodeException Sep 04 '17 at 17:15
-
1
-
-
You're welcome, I also learned some new things. :) If you think I answered your question, please [accept it](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) for further references. – juzraai Sep 04 '17 at 19:46