Home > Enterprise >  How should i export jar when they depend on each other?
How should i export jar when they depend on each other?

Time:08-12

If I have 3 java projects: A, B and C

Where A use classes from B, and B use classes from C

How should I export the project A?

Should I export C, add it to the project B and then export B and add it the jar to A?

And if I have to update C, I have to repeat what I have done before?

CodePudding user response:

Considering the tags java and jar. All you need is to have b.jar and c.jar in the classpath of a.jar.

Just export the 3 jar and run on this way:

java -classpath b.jar;c.jar;a.jar package.mainclass

But it's wrong to say that they depend of each other. When it happens it is like a depends b that depends a. It's an error and it can't happen.

CodePudding user response:

You can add both to project A

You don't have to add C to B and B to A, You can add C and B to A

Your jar file will look the same if you add C to B and then B to A or add C and B to A

  • Related