About Java Project Packaging

Source: Internet
Author: User
Tags log4j

You can choose from the following methods:

First, using Eclipse, right-click the project to export the jar.

Second, using Eclipse, right-click the project to export the runnable jar.

Third, use the Eclipse plugin fat jar to export the executable jar package.

There is now a development scenario:

First project: A1

Second item: B2

Item Three: U3

Several conditions and relationships:

1 U3 references third-party libraries Log4j.jar and common-Io.jar.  2B2 referenced the project U3.  3 A1 referenced the project B2.

I want to implement an operation like this:

1 U3 and third-party libraries are packaged into a jar package "U3.jar".  2u3.jar Import the Project B2, package it into a new jar package "B2.jar".  3 b2.jar Import the project A1 for A1 use.

The purpose is simple:

Import a B2.jar without importing a variety of third-party libraries.

Tried the various packaging methods failed.

It looks like the U3.jar contains Log4j.jar and Common-io.jar, and then the project A1 hints that the related class could not be found!

A few hours later, a little depressed, isn't it?

However, this is only a question of the feasibility of thinking.

It looks like jar packages are available, but it is not found when loading class from A1 because the path is not correct.

On the other hand, it is more scientific to import third-party libraries separately with the tips of project dependencies.

To look at a situation like this:

1 New projects U4 also uses third-party libraries log4j-1.0. jar.  2U4 and third-party libraries are packaged into a jar package "U4.jar".  3The third-party libraries in U3.jar and U4.jar can take effect.  4 project A1 also imported U3.jar and U4.jar, it seems, the conflict scene appeared.

Even if the version of Log4j.jar is consistent, it is not elegant to load multiple identical jar packages.

So, package the project into a referenced jar package, just hit the class that you wrote, and make the third-party jar package more scientific in a way that relies on it.

About Java Project Packaging

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.