[J2se] Introduction to jre jdk and SDK

Source: Internet
Author: User

JRE: Java Runtime Environment.
JDK: it is the basis of all Java applications. All Java applications are built on it. It is a set of APIS, or Java class
SDK: software development kit
Http://java.sun.com/products/
1. the SDK (software development kit) helps developers improve their work efficiency. Different types of software development can have their own sdks. Windows SDK, DirectX SDK, And. Net SDK. Java Development is also unambiguous and has its own Java SDK.
2. JDK: Java SDK was first called Java software develop kit and later renamed JDK, namely Java Develop Kit. As a Java Development Kit, JDK is mainly used to build applications, applets, and components running on the Java platform.
3. JRE (Java Runtime Environment, Java Runtime Environment), that is, the Java platform. All Java programs can run only under JRE. JDK tools are also Java programs, and JRE is also required to run. To ensure JDK independence and integrity, JRE is also a part of JDK installation. Therefore, there is a directory named JRE under the JDK installation directory to store JRE files.
4. JVM (Java Virtual Machine) is part of JRE. It is a fictitious computer that simulates various computer functions on an actual computer. JVM has its own complete hardware architecture, such as processor, stack, and register, as well as corresponding command systems. The most important feature of Java is cross-platform running. JVM is used to support cross-platform operations that are irrelevant to the operating system.

Therefore, the JVM of the Java Virtual Machine belongs to JRE, and now we have installed JRE when installing JDK (of course we can also install JRE separately ).

When I started to contact Java, I felt that the Java Virtual Machine was very troublesome. I don't understand the difference between JRE and JDK?

Later I figured out that JRE is a runtime environment and JDK is a development environment. Therefore, JDK is required for writing Java programs, and JRE is required for running Java programs. JDK already contains JRE, so Java programs can run normally when java_home is set to JDK. However, JDK contains a lot of content unrelated to running, therefore, you do not need to install JDK to run common Java programs.

But I have doubts when I use eclipse. Why can this development environment JRE run normally? In fact, the Java compiler is embedded in eclipse and is fully compatible with javac in JDK. Therefore, you can directly compile Java programs without using JDK.

I didn't understand why Tomcat and apusic can be started with JRE, and WebLogic can be started with JDK? The reason is that both Tomcat and apusic 4 have included a source code compiler, while WebLogic does not include this compiler package.

So why do we need a compiler? In Web applications, JSP files need to be converted to servlets. This Servlet File also needs to be compiled into class files that can be executed on JRE. Therefore, JDK with compilation capability must be provided, set java_home to the JDK path.

What about the new apusic 5.0? In order to allow you to flexibly adjust the JVM version, this version does not provide the built-in Java compiler, but uses the JDK installed by the user to compile the JSP, this is why apusic 5.0 must be started through JDK.

JDK is the Java Development Kit.
JRE is the Java runtime enviroment, which refers to the Java Runtime Environment and is intended for Java program users rather than developers.

If JDK is installed, there will be two sets of JRE in your computer, one in the/JRE and the other in the C:/program files/Java/j2re1.4.1 _ 01 directory, this later set is less server-side Java virtual machine than the previous one, but simply copy the previous server-side Java virtual machine. When installing JDK, you can choose whether to install the JRE in the C:/program files/Jav a directory. If you only install JRE instead of JDK, only a unique set of JRE will be installed in the C:/program files/Java directory.

The status of JRE is just like that of a PC. The Win32 application we write requires the operating system to help us run it. Similarly, the Java program we write must also run JRE. So after installing JDK, if two sets of JRE are installed in two different locations on the hard disk, you can imagine that your computer has two virtual Java PCs, all have the function of running Java programs. So we can say that as long as your computer has installed JRE, you can run the Jav a application correctly.

1. Why does Sun need JDK to install two identical JRE? This is because JDK has a lot of Java-compiled development tools (such as javac.exe‑jar.exe), and they are all stored in/lib/tools. jar. As shown in the following example, change tools.jarto tools1.jarand run javac.exe. the following result is displayed: exception in thread "Main" Java. lang. noclassdeffounderror: COM/Sun/tools/javac/Main. You can input javac.exe and Java-cp c:/JDK/lib/tools. jar COM. sun. tools. javac. the main is the same and the same result is obtained. From this we can prove that javac.exe is just a wrapper, and the purpose is to prevent developers from entering too long fingers. In addition, we can find that the programs in the/lib directory are very small, not greater than 2 9 K. Here we can draw a conclusion. That is, JDK tools are almost written in Java, so they are also Java applications. Therefore, to use the tools attached to JDK to develop Java programs, you must also attach a set of JRE, therefore, the set of JRE located in the C:/program files/Java directory is used to run general Java programs.

2. If two or more JRE are installed on a computer, who will decide? This major task falls on java.exe. The job of java.exe is to find the appropriate JRE to run the Java program. Java.exe searches for jre in the following order: whether JRE is in its own directory; whether JRE is in its parent directory; and query the registry: [HKEY_LOCAL_MACHINE/software/kerberoft/Java Runtime Environment] The running result of java.exe is closely related to which JRE is executed on your computer.

3. Introduction The bin directory under the jvm jre directory has two directories: server and client. This is where the real JVM. dll is located. JVM. DLL cannot work independently when JVM. after the DLL is started, it will use the explicit method (that is, using loadlibrary () and getprocaddress () in the Win32 API to load the dynamic link library of the auxiliary ), these auxiliary Dynamic Link Libraries (. DLL) must be in the JVM. the parent directory of the dll Directory. Therefore, you only need to set the path to the JVM. dll under the directory where JRE is located.

The distinct between JDK and JRE:

The JDK implements des a Java compiler (javac), a Java Virtual Machine (Java), and all of the standard Java library components -- in other words, everything you need to write Java programs in a wide variety of problem domains, and more than enough firepower for the assignments we'll be giving you. (The JRE is the Java Runtime Environment, which has des the necessary code to allow youRunJava programs, but not to write and compile them! The JRE will not be sufficient for our work in this course .)

The job of the path and classpath environment variable:

You can execute programs from a command prompt (or, as Windows 95/98 call it, an "MS-DOS prompt") by simply typing their names, such as javac or Java. but there's a catch: Windows has to know where it canFindThese programs. This is the job of the PATH environment variable. path is a list of folders, separated by semicolons, in which Windows will look for a program whenever you try to execute one.

Similarly, whenever the Java compiler or Java Virtual Machine need to be able to use a Java class (such as when you import a class from the Java Library ), the compiler or virtual machine needs to be able to know where to find it. this is the job of the classpath environment variable. classpath is a list of folders, separated by semicolons, in which the Java compiler or virtual machine will look for a Java class whenever it's trying to find one.

So, to make the JDK work, you have to modify the path and classpath environment variables on your system, so that windows will be able to find javac and Java, and so that javac and Java will be able to find all of the necessary Java classes.

What are the environment variables path and classpath?
PathIs the environment variable provided by your operating system,
You must have tried to enter a command in the command line and then it will be executed. For example, you entered> FFFF,
But this file is clearly in the path D:/*****/***/ffff.exe and can be executed in the command line regardless of input in that path,
This is because the path is set in the path.
So what is the role of classpath? I know the role of import when compiling Java programs!
When the class to be used is in A. jar file, you need to introduce it during compilation. JVM automatically finds the classpath environment variable and introduces the following jar package,
This is the role of the classpath environment variable.

Path =.; C:/j2sdk 1.4.2 _ 05/bin; D:/downloads/Oracle/Apache/perl/5.00503/bin/mswin32-x86; C: /program files/Oracle/JRE/1.1.7/bin; % SystemRoot %/system32; % SystemRoot %/system32/WBEM; D:/downloads; C: /program files/Symantec/pcAnywhere/; C:/program files/Microsoft SQL Server/80/tools/binn

Java_home = C:/j2sdk 1.4.2 _ 05

Classpath =./; % java_home %/lib/tools. Jar
(Path does not use the java_home variable)

Path and classpath are different from environment variables. What is path and classpath? path is the environment variable provided by your operating system. You must have tried to enter a command in the command line and then it will be executed, great. The class to be used is in. in jar, you need to introduce it during compilation. JVM automatically finds the classpath environment variable and introduces the following jar package. This is the role of the classpath environment variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.