Difference between bin's java.exe and JRE's 'java.exe'
I am new开发者_Go百科 to Java. I have a confusion which interpreter is used to execute Java programs as I can see two java.exe, one inside the bin folder and the other inside JRE's bin folder.
I want to add some details to clear my query:
Suppose Java is installed in C:\Program Files\Java\Jdk1.6. Now, in this directory there is the jre folder, bin folder, and other folders as well, but let’s concentrate on these two. This ..\jre\bin folder contains java.exe and the ..\bin folder also contains java.exe. So, my concern is: Which Java interpreter is used to execute Java programs?
From the Java SE installation notes:
http://www.oracle.com/technetwork/java/javase/documentation/install-windows-142126.html#private
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 atC:\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).
So I think you should use executables from the /bin directory when executing Java programs.
JRE: Java Runtime Environment. It is basically the Java Virtual Machine where your Java programs run on. It also includes browser plugins for Applet execution.
JDK: It's the full featured Software Development Kit for Java, including JRE, and the compilers and tools (like JavaDoc, and Java Debugger) to create and compile programs.
Usually, when you only care about running Java programs on your browser or computer you will only install JRE. It's all you need. On the other hand, if you are planning to do some Java programming, you will also need JDK.
Sometimes, even though you are not planning to do any Java Development on a computer, you still need the JDK installed. For example, if you are deploying a WebApp with JSP, you are technically just running Java Programs inside the application server. Why would you need JDK then? Because application server will convert JSP into Servlets and use JDK to compile the servlets. I am sure there might be more examples.
Check the java.home property. It should point to one or the other. Here I get..
Name Value
java.home C:\Program Files\Java\jre6
Please check filesize and filedate of your java.exe
files.
It should be the same.
In my opinion the JDK is a kind of superset of the JRE. So if you need further tools for building or compiling, the JDK is the place to go. Otherwise you can use the JRE
For the paths that you provide, I suppose that you're on Windows.
Now, which java.exe
are you using?
It may depends on what you're executing. If you're running an applet, a jar or Java Web Start, you'll use the java.exe
that is in the bin
directory pointed by your PATH
environment variable. Besides, if you open a console and execute java
you'll run the java.exe
that is pointed by your 'PATH' variable.
If you're running a .bat
file, check if it's used a different environment variable. It's common to use JAVA_HOME
or JAVA_SDK
.
If you installed the JRE, then java.exe should be here C:\Program Files\Java\jre6\bin
If you installed the JDK, then java.exe will be in two places: C:\Program Files\Java\jdk1.6.0_25\bin C:\Program Files\Java\jdk1.6.0_25\jre\bin
If you install both the jdk and jre, you can compare C:\Program Files\Java\jdk1.6.0_25\jre with C:\Program Files\Java\jre6\bin and they will be almost or exactly identical, and you can use the java.exe from either one, but I think most people will use the one in C:\Program Files\Java\jdk1.6.0_25\bin
From my knowledge, I can say there isn't any difference, apart from the purpose of jdk and jre. Both java.exe are the same.
精彩评论