qed
qed

Reputation: 23154

Java equivalent of /usr/lib and /lib?

I am just wondering, if java has something similar to /usr/lib in C/C++, then we won't have to do

java -cp "lib/*" mypackage.MyClass

Instead we can put all our favorite jar files into some folder like /java/lib/ and do

java mypackage.MyClass

Standardization of such a location also saves you the trouble of having to put the same set of frequently used libraries into many projects repeatedly.

Does such a feature exist already?

Upvotes: 0

Views: 88

Answers (2)

icza
icza

Reputation: 418645

Possible other ways ways:

Use the CLASSPATH environment variable. If -cp or -classpath parameters are not specified, the value of the CLASSPATH environment variable will be used as classpath (if it exists). More on setting the CLASSPATH: PATH and CLASSPATH

The META-INF/MANIFEST.MF file inside jars can specify the class path. Add the following line to specify required libraries:

Class-Path: lib/myjar.jar lib/someotherjar.jar

More on this: Adding Classes to the JAR File's Classpath

Upvotes: 0

BaCaRoZzo
BaCaRoZzo

Reputation: 7692

What you are talking about is called the extension folder. Here are summarized some pros and cons about its usage.

Upvotes: 1

Related Questions