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:
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.
Related
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:
Step 1: install jdk. (In C:\Program Files\Java\jdk1.8.0_161)
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?
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
I have a couple versions of java installed (6u32 and 7u21) and recently installed another version (6u37). I have my path variable set JAVA_HOME to a path to my java 7 folder, but after restarting my console java -version still returns java version "1.6.0_37".
EDIT
JAVA_HOME is set in the user variables. So it gets appended at the end of the system variables.
I am guessing that the java.exe in the windows32 folder is version 6u37. In my path Windows32 appears before JAVA_HOME. How do I override the recently installed version of java with the one I set in java home?
Update your system PATH environment variable to reflect the new installation directory.
JAVA_HOME is used by Java once its running, while PATH is used by Windows to determine where exe's are located.
I have a problem involving setting up Java.
I have installed the JRE, added its path to PATH, and set JAVA_HOME and CLASSPATH. Now, java and javacpl work fine, but running javac generates a command-not-found error. Furthermore, javac.exe does not even seem to exist in the JRE's bin folder.
How do I run javac?
The JRE is merely the Java Runtime Environment, which includes only the infrastructure needed to run Java programs that are already compiled.
To compile Java source code using javac, you need the Java Development Kit (JDK).
On Oracle's Java download page, choose the package labelled "JDK".
In order to use javac in cmd , JDK must be installed in your system...
javac will not work if you are pointing "bin" folder inside JRE (C:\Program Files\Java**jre7**\bin)
Please check for javac.exe inside your bin folder(C:\Program Files\Java**jdk1.7.0_45**\bin)
javac.exe must be inside JDK(C:\Program Files\Java\jdk1.7.0_45\bin) not inside JRE (C:\Program Files (x86)\Java\jre7\bin) "JRE doesn't come with a compiler. It is simply a java runtime environment. What you need is the developmental kit." in order to use compiler javac
For javac path(Points to remember while setting system env variable)
path = C:\Program Files (x86)\Java\jre7\bin this is wrong
path = C:\Program Files\Java\jdk1.7.0_45\bin this is correct
Make sure "javac.exe" must be inside your "C:\Program Files\Java\jdk1.7.0_45\bin"
Dont confuse with JRE and JDK both are totally different
if you dont have JDK pls download from this link http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
reference thread for JDK VS JRE What is the difference between JDK and JRE?
Procedure:-
Install JDK
open cmd prompt
type "cd C:\Program Files\Java\jdk1.7.0_45\bin " press enter(path may change based on jdk version and 32bit and 64bit os version)
type "javac" press enter
its done
Now go and change your system environment variable
path = C:\Program Files\Java\jdk1.7.0_45\bin
this will set the path permanently
The JRE doesn't have javac - you need to download the JDK (Java Development Kit).
First, you need to install the jdk, then add the path of bin folder of jdk in the path vaiable.
you can refer to this link
I have tried to install sdk bundle on windows 8 64 bit and windows 7 64 bit machines.
After unpacking to c:\development dir I try to run te eclispe.exe from \adt-bundle-windows\eclipse and I get same error for both:
![error message][1]
"a java runtime enviroment JRE or JDK must be available to run eclipse. No java virtual machine found in c:\development\adt-bundle-windows\eclipse\jre..."
There is no jre directory in the installed c:\development... therefore the error.op
I tried installing java manually to the eclipse directory but it did not create a jre directory so error came up the same.
My understanding from the install instructions is that everything needed is provided in the "bundle"!
What am I missing? Why is the java stuff not there?
If you have the JRE installad on your machine, then go to Properties of my computer > Advanced tab > Select Environment Variables
Then in the section of System variables, look for the variable "Path" and edit that, and add you JRE path there with a semicolon.
like
";C:\Program Files\Java\jre7\bin"
What exactly is the purpose of JDK - running java programs or developing?
There seems to be too many packages that include java and jdk/sdk in their title. Which one should I install if I want to develop Java applications?
Who uses JAVA_HOME and what should I set it to be?
JDK is development environment. JVM is runtime environment.
You should download java installer from oracle web site or install it from repositiry manager
JAVA_HOME system variable usually is required for enterprice java software (application servers, DBs, development tools and so on). You should set JAVA_HOME variable to root directory of JDK or JVM(setting it to JDK always works, but maybe some software will run as expected with JAVA_HOME pointing to JRE). If you set JAVA_HOME right then $JAVA_HOME/bin/java -version command should pring version of java.
JRE means Java Runtime Environment. Most Java Software only needs a JRE to run.
JDK means Java Development Kit. A JDK allways includes a JRE. If you develop you most certainly allways use the JDK, since it contains source and docs of java's own Classes.
Also there is software (usually software for development) that uses tools of the JDK to run, e.g. this software needs the JDK as runtime environment (for example: ant).
JVM means Java Virtual Machine and is the program that runs your java program no matter if in JRE or JDK.
JAVA_HOME is the path to the JDK
JRE_HOME is the path to the JRE
JDK - Java Development Kit (in contrast to JRE - Java Runtime Environment).
If you don't know which version of Java you need, just get the latest (currently Java Platform (JDK) 7u5). Unless you already have a development tool, you might want the Netbeans bundle instead.
JAVA_HOME is used by some software that depends on Java - ant, which is a build tool, is one that comes to mind. It should be set to the directory which contains the bin directory, which in turn contains the java executables.