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