Can this way import multiple jars?
set CLASSPATH=C:\dependency\*;C:\location\*
Is this means all jars below the dependency is imported?
Wildcards are allowed in the latest Java 6. See the document for details:
http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
Let's take a look at this example
java -classpath "./libs/*" Test
The *
here refers to all jar files in the LIBS directory. You can't write java -classpath "./libs/*. jar"
test like this
If there are both jar files and class files in the LIBS directory, we all want to reference them, so we need to write
java -classpath "./libs/*;./libs/" Test
Note: in Windows system, the separator is;
in UNIX system, the separator is:
Note that LIBS/*
does not contain jar files in subdirectories under LIBS directory, such as LIBS/folder1/a.jar
If you want to include subdirectories, you need to be clear about them, such as
java -cp "./libs/*;./libs/folder1/*" Test