Specifying a class path for classes inside the JAR itself

If I have an org.foobar.MyClass class and you want to put it in a JAR file, I have to put it in the JAR / org / foobar / directory or I can put it in / bin / org / foobar / and somehow specify / bin / how is the classpath inside the JAR itself?

+3
source share
5 answers

The usual way that everyone does this — until now I have never seen the JAR do something else — is to put the org.foobar.MyClass class in the JAR file in the JAR directory / org / foobar /. I can’t imagine a good reason to do something differently, as this will prevent the normal use of this JAR by anyone who doesn’t do unusual things.

+1

Class-Path , , . JAR.

, app.jar MANIFEST.MF:

-: lib1.jar, lib/lib2.jar

JVM lib1.jar , app.jar, lib, lib2.jar.

+2

, , MANIFEST. , .

0

jar . , , , .

"" jar, URL- . , , URLClassLoader ( ).

A function that exists as a standard is to add other jar files to the classpath by specifying them in the manifest.

0
source

Why would you do this? It’s easier to just put it in the correct directory based on the package name, which eliminates the need to edit the MANIFEST file or make any other special settings.

-1
source

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


All Articles