Tips for managing jar packages in MyEclipse

Source: Internet
Author: User

In the process of doing enterprise-level development with myeclipse, we often touch many jar packages, including the following: One is the jar package on the application server, the other is the jar package required for the project, and the third is the jar package required for the development environment. It is clear that jar packages are so important that without them it is difficult to use encapsulation/modularity/reuse in an artistic way.

Therefore, it is necessary for us to make a more comprehensive understanding of the introduction/management of jar packages involved in project development, and pave the way for further development efficiency.

one. How to import jar packages

A. Right-click on the Project "MyEclipse" menu and select the corresponding jar package by directly using the relevant project jar package from the MyEclipse, for example "Add hibernatecapabilities", And can set some of hibernate configuration information, good visual operation;

B. Add the external jar package to the Web project's Lib package and right-click the project "Properties"--"Java Build Path"--"Libraries" tab;

C. Manually copy the jar file to the project Lib package, the specific operation as long as the jar file to be added to the MyEclipse in the workspace of the Lib package is good;

The above three ways to import jar package can be, but how to choose it? for Mode 1, the jar file is directly linked to the MyEclipse file, and is not copied to the Web-inf/lib directory, and may not be used for project release, porting, or the jar cannot be found. ; Mode 2 also has this disadvantage; Mode 3 is added directly to the Web-inf/lib directory, with strong portability and strong operability. It is recommended to use a third way, personal preference only.

Two. jar Package display hidden mode

Different developers have his own inherent development habits, and some people feel that the jar package displayed in the development view is too unsightly, looks uncomfortable, complex. Some people want to look at what jars are being introduced, what techniques are used, and view the source code directly by clicking on the class file in the jar package (assuming that the source was previously imported). So, there's a problem with the display and hiding of a jar package: In the Packages Explorer form, there's 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, tick the check box to indicate that this type of file is not displayed, multiple types can be", "delimited.

Three. Remove jar package affinity warning from eclipse

We are exposed to two environments in the development process: the development environment (corresponding to the classpath in Eclipse) and the runtime environment (corresponding to the classpath in the application server). The relationship between jar packages in both environments is more complex. The overall principle of dealing with the relationship between jar packages is to keep the version of the jar package consistent or compatible in both environments.
The jar package in the project Web-inf/lib directory is a common part of both environments. This part of the jar package requires no conflict with the jar packages in both environments, meaning that the jar package in the Lib directory is complementary to the jar packages in both environments. The jar packages in both environments should, in principle, be the same or compatible.
For example, in the development of Java EE Projects under Eclipse, we will use the Java EE related jar package Javaee.jar, when the requirements of the development environment. However, this jar is not needed in an application server environment because the application server will have the associated Java EE jar package. In this case, if we publish the project to the application server environment, a jar package conflict will occur.  However, we need to use this package when we are developing, and we can't publish it to the application server when we publish it. The solution is as follows:
Add this jar package to eclipse (this jar is not in the project directory, of course), and Eclipse will prompt:

Classpath entry Xxx.jar won't be exported or published. Runtime classnotfoundexceptions may result.

Classpath entry Xxx.jar won't be exported or published. Runtime classnotfoundexceptions may result.


Because we are now confirming that this jar is not required to be deployed to the application server environment (just put it in the Lib directory if needed), so let's do the following to dismiss the eclipse dependency hint:

Point in the message-right-click-->quick fix->exclude The associated raw Classpath entry from the set of potential Publish/export Depe Ndencies-->finish.

This removes the dependency on the jar package, which will not appear in the project when it is released.

Tips for managing jar packages in MyEclipse

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.