Java:java Base-jar Package Add to build path description __ Storage

Source: Internet
Author: User
Tags java web

In Eclips, on the project name, right-->build path->contigure Bud Path->java Build path has a

Libraries->add External Jars

Add Jars

Add Library

Add Class Folder

What are these buttons for?

 

categories Explain the meaning of these options:

Add external jars = increase the package outside the project
Add jars = Add Project Inner pack
Add library = Add a library
Add Class folder = Add a class folders
The following highlights the user libraries in the Add library

Add the user Library by doing the following:

1. Selected project right key->build Path->add libraries ...

2. Select User Library->next

3. Click the User Library button

4. Click the New button

5. Enter Library name (I want to import a struts 2.1.6 jar package and a JDBC jar package that you can use as a Struts 2.1.6 library for easy memory)

6. Click OK

7. Select the user library, and then click Add Jars

8. Find the corresponding jar package, in turn, OK.

 

The User liberary is added to eclipse, only in Eclipse, where Eclipse knows where the referenced classes are, but if you want the Web project to start properly, tell the Tomcat container, Where is your jar bag (placed in the Lib directory, the container will know). So that's what happens, in Eclipse, add User library, just for debugging, do not join the user library, eclipse can not find the import of the class, there will be a red X, do not put the jar package in the user library under LIB, capacity can not find the introduced class, will be an error.

 

The difference between the Add jar and add external jars and the user libraries in the Add library is:

jar Packages added through "Add Jar" and "Add external jars" are packaged into the final program as part of the program. The jar package added through "User libraries" is not.

 

about the role of the jar package build path:

jar packs cannot be in a random place. Whether it's Java application or Java WEB application.

The Java Virtual machine is based on the Java ClassLoader (ClassLoader) to determine how to go there to load class:

The reason we put the jar bag under classpath is because of the existence of Classpath ClassLoader

we can not specify some jar packages in classpath, but they can also be used in Java programs.

that's because the parent class loader with Classpath ClassLoader is responsible for loading. such as the JRD directory Jre\lib\*.jar

The reason we put the jar package into the Lib folder under Webroot and can be used in our program is that the container implements its own classloader. (The Web Middleware server class loading mechanism differs from the 3 default loaders provided by Sun.) )

So the jar can be loaded, where the jar is loaded, is determined according to ClassLoader.

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