Eclipse Add in Jar package

Source: Internet
Author: User

Personal preference Java A very important reason for having a rich jar library can be used. The JAR (Java Archive) is a compressed document format for Java, based on the popular ZIP file format. Unlike zip, jar files can be used not only for compression and publishing, but also for deploying and encapsulating libraries, components, and plug-ins, and can be used directly by tools such as compilers and JVMs. In the actual development process, the spirit of "take doctrine" the idea, often directly use others have developed the jar package, avoid repeating "build wheel", improve project development speed. This article has collated several ways to add jar packages to your project. Depending on where the jar is stored, there are two ways to add a jar: Add an internal jar and add an external jar.

Jars that were successfully added to the project by eclipse are displayed uniformly under the referenced libraries directory, as shown in:

1. Add an internal jar

If the jar file you are adding is already in the project directory, you can think of this jar as part of the project, so this can be called adding an internal jar. The benefit of this is that when the project is moved to another environment, the jar packages are moved together without the case of missing classes in the jar.

To add an internal jar, first place the jar in the project. In Eclipse, select Project, right-and new folder, create a new file called Lib, which holds all the jar packages used by the project.

Copy the jar file into the Lib folder, F5 refresh the project, and you will see the Lib folder containing the jar package.

1.1 Adding an internal Jar Method 1

Select the jar package under the Lib folder, and the ADD to build Path,jar package, right-click Build Path, will be moved from the LIB to the referenced libraries directory:

1.2 Adding an internal Jar Method 2

Select Project, right-click Build path, Configure build path ..., the Project Properties dialog box looks like this:

Click the Library tab, click the "Add JARs ..." button, in the Jar selection dialog box, select the jar file in the project's Lib directory and click "OK".

2. Add an external jar

If the jar package is not in the project directory, but is stored outside the project directory, it is called adding an external jar. In this case, the project is moved to another environment, or the path to the jar is changed, and the jar file cannot be found. Therefore, this approach is more suitable for applications where the project location does not change.

2.1 Adding an external jar Method 1

Select Project, right-click Build path, Add External Archives ..., as shown in the action path:

In the Jar Selection dialog box, after selecting the external jar, click "Open":

2.2 Adding an external jar Method 2

Select Project, right-click Build path, Configure build path ..., the Project Properties dialog box looks like this:

Click on the Library tab and click on the "Add External JARs ..." button to select the external jar in the Jar selection dialog box in Add external Jar Method 1.

Eclipse Add in Jar package

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.