JDK, JRE, JVM relationship If JDK is installed, there are two sets of JREs in the same you, a set of / jre additional set of C: / Program files / Java / J2re1.4.1 The _01 directory is next to the Java virtual machine that is less than the server-ended Java virtual machine, but directly copy the server-end Java virtual machine in front of the front. And in installation JDK, you can choose whether to install this JRE in the C: / Program Files / Java directory. If you only install JRE instead of JDK, you will only install a unique set of JREs in the C: / Program Files / Java directory. JRE's status is like a PC, we write Win32 applications require operating system to help us run, the same, the Java program we have written must also be run. So after you installed JDK, if you have two sets of JREs on the two different places on the hard disk, you can imagine that your computer has two virtual Java PCs, all of which run the Java program. So we can say that as long as your computer has JRE, you can run Java applications correctly. 1. Why is Sun to make JDK installed two sets of JRE? This is because there are many development tools (such as JavaC.exe, Jar.exe et al., Are placed in the /lib/tools.jar. As can be seen from the following example, first rename Tools.jar is Tools1.jar, then run JavaC.exe, show the following results: Exception in thread "main" java.lang.noclassdeffounderror: com / sun / Tools / javac / main Means, you entered JavaC.exe and input
Java -cp c: /jdk/lib/tools.jar com.sun.tools.javac.main
Yes, it will get the same result. From here we can prove that JavaC.exe is just a wrapper, and the purpose of making it is to let developers from input too long. And you can find that the program in the / lib directory is small, no more than 29K, from here we can draw a conclusion. The tool in JDK is almost written in Java, so it is also a Java application, so use JDK's tool to develop Java programs, you must attach a set of JREs, so at C: / Program Files / The set of JREs in the Java directory is used to run a general Java program. 2, if a computer is installed two sets of JRE, who will decide? This major task falls on Java.exe. Java.exe's job is to find the appropriate JRE to run the Java program. Java.exe finds JRE: There is no JRE in your directory; the parent directory has jre; query registry: [HKEY_LOCAL_MACHINE / SOFTWARE / JAVASOFT / JAVA Runtime Environment] So Java.exe's run results with you Which JRE is executed in the computer is executed. 3. Introduction to the bin directory under the JVMJRE directory: Server and Client. This is the real JVM.dll. JVM.dll can not work separately. When JVM.dll is launched, use Explicit method (that is, using loadLibrary () in Win32 API to load auxiliary dynamic link library), and these auxiliary Dynamic Link Library (.dll) must be located in the parent directory of the JVM.dll. So, which JVM wants to use, just set PATH, point to JVM.dll under the directory where JRE is located. 2, if a computer is installed two sets of JRE, who will decide? This major task falls on Java.exe. Java.exe's job is to find the appropriate JRE to run the Java program. Java.exe finds JRE: There is no JRE in your directory; the parent directory has jre; query registry: [HKEY_LOCAL_MACHINE / SOFTWARE / JAVASOFT / JAVA Runtime Environment] So Java.exe's run results with you Which JRE is executed in the computer is executed.
1) NOT EXACTLY, JAVA EXECUTABLE IS PART OF One JRE ON YOUR PATH. UNSE.EX UNIX SOMEWHERE ELSE. 2) Another Problem is if you put two iMcompatable Jres on Your machine, it might cause your ObjectInputStream corrupted.3) For developer's machine, j2sdk without another JRE is the best choice Add one more:. Even j2sdk (JDK is the old name) is free, but it is illegal to distribute j2sdk with your product . Therefore if your product required j2sdk to run. Then you must require your client to download it from Sun and install it before instalation of your product. What a headache! On the opposite, you can distribute JRE with your application freely.javac is Sun's version of java compiler, not a wrapper. Like any other executables, it uses other libraries such as some dll on windows, some shared libraies on Unix. It also uses some jar files came with it. That is just how it is, and how IT Works. IT IS QUITE NORMAL, ISN 'ket?
javachina wrote:.. 1) Not exactly, java executable is part of one JRE on your path Unless you put java (.exe ?? There is no java.exe on unix) somewhere else 2) Another problem is if you put two imcompatable Jres on Your Machine, IT Might Cause Your ObjectInputStream Corrupted.3) For Developer's Machine, J2SDK WITHINE, J2SDK WITHOUT ANOTHER JRE IS The Best Choice.
Java -cp c: /jdk/lib/tools.jar com.sun.tools.javac.main
javachina wrote:.. 1) Not exactly, java executable is part of one JRE on your path Unless you put java (.exe ?? There is no java.exe on unix) somewhere else 2) Another problem is if you put two imcompatable Jres on Your Machine, IT Might Cause Your ObjectInputStream Corrupted.3) For Developer's Machine, J2SDK WITHINE, J2SDK WITHOUT ANOTHER JRE IS The Best Choice.