Differences in how several packages are added in eclipse

Source: Internet
Author: User

Reference: http://blog.sina.com.cn/s/blog_4dbc82e101000bg2.html

http://cuics-100.javaeye.com/blog/652255

The jars in Java are so important that without them, we cannot make such artistic programs: encapsulation, modularity, multiplexing, and so on (no ant, Marven way).

Today, I'm going to sort out some of the ways to add management to jar packs in a project and solve common problems:

1, jar Import into our web project under the Classpath

1 here, one method is, directly with the relevant project jar package MyEclipse, right click on the project "MyEclipse" menu, select the corresponding jar package on OK, example "ADD Spring capabilities", And you can set some of the configuration information of spring, good visualization operation;

2 Add the external jar package to the Web project's Lib package, right-click the project "Properties"--> "Java build Path"--> "Libraries" tab (of course, this is not just a way to add a jar pack);

3 Manually copy jar files to the project's Lib package, the specific operation as long as the jar file to be added to the MyEclipse in the workspace under the Lib package is good; ( after adding the project can sometimes not find the jar package, Need to refresh or reboot MyEclipse)

At this point, the jar file is added OK, so Easy!jar is added, but what is the difference between these several, then how to manage it, and then look at the 2nd

2, three kinds of jar package add way, all can make sense, very ok, then how to choose decision?

1 This way, the jar file directly linked to the MyEclipse file, and did not copy to the Web-inf/lib directory, not to use the project release, transplant, the jar can not find the situation;

2 Selective comparison of the strong, can be arbitrary add jar package, as long as you have this machine exists on the link is also the absolute path of the jar file, the disadvantage of the same 1;

3) directly added to the Web-inf/lib directory, the transplant is strong, operability is also strong.

In a word, 3rd, the way the jar package is imported, I think it's a good one.

3. Show/Hide jar file in Project

Different developers, all with his inherent habits, some people feel that the jar package display in the development view is too unsightly, look uncomfortable, complex. And some people, he just want to look at what technology is used to guide the jar package, and by clicking the class file in the jar bag to view the source directly (assuming there was previously imported source code). So, here's the problem with the display and concealment of a jar package: In the Package Explorer form, there is a drop-down triangle in the upper right corner, click--> "Filters"--> Name Filter Patterns (matching names will is hidden) ", under this option, fill in the *.jar, check box that indicates that this type of file is not displayed, multiple types are available between", "delimited.

4, in the Eclipse Project Java build path setting, you can add a third party jar package , but I found there are several ways to do this, there are "add jars", "Add Externel jars", "add Library "," Add Classes Loader "and so on, what are the differences in these ways?
The add jar is an indication of adding a jar from your project if you put the jar in your own engineering directory.
The add external jar indicates that the location of the jar requires a URI to locate, and a full path is required.
The Add library is a collection of already-defined jars, because they are often used together, so it simplifies operations, such as when you do RCP development, a plugin library contains the basic plug-ins needed to run the project.
Add classes Loader-This should be Add Class folder bar. This is the same as adding a jar, which means telling ClassLoader where to find class.

5. When Java.lang.ClassNotFoundException appears: Org.springframework.web.context.ContextLoaderListener like this exception that cannot find listener, remember that spring's jar package must be placed under the engineering Lib to avoid this error.

add: Although importing packages in any way is the same, but in fact when I run, some only Java build path works, some only to import into the LIB, it is possible that I now use the Framework Goolge app Engine , which is still under study.

Added above: There is a difference between using Java build path to import packages and copying packages to Lib, and they don't actually conflict, and it doesn't matter, Java builds path is the package we need to compile, like in import ***.***.*** If you don't use Java build path to import the package, there is a red fork in the class that does not recognize this class; Importing to Lib is the package that the program needs to run, even if the package imported with Java build path is not placed under LIB, A classnotfoundexception exception occurs when you run the project.

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.