Can I call the class files that are in the jar library located in another jar file?

I am trying to access class files packaged as a library, but unfortunately jar libraries need to be packaged into another jar file.

As an example, let's say that I have a.jar that contains some class libraries. I can call (import) classes in a jar file from my external Java application. Now I need to put this a.jar in another jar, say b.jar, and you need to access (import) the classes in a.jar from outside b.jar.

This is not what I want to do :)

+3
source share
2 answers

, " ". .

jar - . , , . ...

+6

, , , JAR () .

, , ​​ A.jar - B.jar. (: ; Windows):

java -cp A.jar:B.jar main.class.Name args

main.class.Name - , args - .

Main-Class Class-Path manifest.mf :

Class-Path: B.jar
Main-Class: main.class.Name

:

java -jar A.jar args

, , JAR , JAR . , , , , , , . JAR, .

Class-Path manifest, , , JAR ( java -jar "), , .

JAR ( lib) Class-Path , JAR "lib/B.jar". , JAR.

+1

Source: https://habr.com/ru/post/1714841/


All Articles