java-two JRE directories and three Lib directories-go

Source: Internet
Author: User

The jar package is placed in the Lib directory. The import statement in the program is looking for these files! For example: Import Javax.servlet.RequestDispatcher;
The problem is, in the CMD mode, the system will prompt: Package javax.servlet does not exist!

After installing the JDK, take a closer look at the folder under the installation path, which contains a total of two JRE directories! There are three LIB directories! The jar package containing the javax.servlet should be placed in one of these places. First, under the Tomcat installation directory, locate Servlet-api.jar (located in D:\Program files\apache software foundation\tomcat 6.0\lib\servlet-api.jar). This pack winrar decompression to see the internal structure:
Identical to the structure of the import statement!

On my hard drive, the Lib folder is located as follows:
D:\Program Files\java\jdk1.6.0_02\jre\lib
D:\Program Files\java\jre1.6.0_02\lib
D:\Program Files\java\jdk1.6.0_02\lib
Lib under the lib;jdk under the Lib;jre under the JDK, respectively.
After verification, the Servlet-api.jar package copy into the JDK under the JRE under the EXT directory, the import statement passed the compilation! That is: C:\Program files\java\jdk1.5.0_08\jre\lib\ext related, other jar packages imported from the outside, are placed in this directory. For example: Importing the MySQL driver jar "Mysql-connector-java-3.0.17-ga-bin.jar" in the project, essentially copying the jar package to the EXT directory. In other cases, the addition of the Oracle driver jar package is also handled similarly.

To explain why there are two JRE directories? What are the functions of the three LIB directories?
After installing the JDK, there are JDK and JRE two folders in the Java directory, but there is a JRE folder under the JDK, and this JRE has more server folders than the previous JRE in the bin directory!
Ordinary users can install the JRE. The developer needs to install the JDK, which includes the JRE. So the JRE directory is included in the JDK directory. The two JRE is roughly the same, with subtle differences.
Two sets of JRE are for different job responsibilities! Different JRE is responsible for the contents of the respective scopes.
When the user only needs to execute the Java program, then the C:\Program files\java\jre1.5.0_08 JRE is OK!
When the user is a Java programmer, the Java development environment is required. At compile time, the system will take precedence to find the "Java, Javac" directories under C:\Program Files\java\jdk1.5.0_08\bin or the JRE of their parent directory. That is, the JRE under the JDK is running under the development environment.

Again, three Lib directories:
The Lib under the JDK includes the jar package for the Java development environment, which is for the JDK, such as some tools under the JDK that might be used for files in that directory. For example, compilers, and so on.
Lib under the JRE is just a jar package that runs Java programs and is used for the JVM runtime. Includes all the standard class libraries, and extension classes.
The Lib under the JRE under the JDK is the jar package required by the runtime in the development environment. The most typical is the imported external drive jar package. Because at compile time, the system is looking for the JRE under the JDK. Instead of the outermost JRE.

java-two JRE directories and three Lib directories-go

Related Article

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: 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.