Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include all the jars present at a particular directory in the CLASSPATH in one go? [duplicate]

Tags:

I have around hundreds of jars at a particular directory which my application uses. So I thought its hard to add each jars one by one to the classpath. So is there any command or any way so that i can add all the jars at one go. some *.jar should add all the jars.

like image 512
GuruKulki Avatar asked May 02 '11 12:05

GuruKulki


People also ask

How do I include all JARs in a folder classpath?

In general, to include all of the JARs in a given directory, you can use the wildcard * (not *. jar ). The wildcard only matches JARs, not class files; to get all classes in a directory, just end the classpath entry at the directory name.

How do I find the classpath of a jar file?

To check our CLASSPATH on Windows we can open a command prompt and type echo %CLASSPATH%. To check it on a Mac you need to open a terminal and type echo $CLASSPATH.


1 Answers

Yes, you can use a wildcard, as of Java6. See the section on "Understanding class path wildcards"

Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/* specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.

Prior to Java 6, you had to specify them all individually.

like image 176
skaffman Avatar answered Jan 28 '23 03:01

skaffman