Java classpath and wildcards

Pretty useful thing about the Java classpath definition is that the wildcard () can be used in a replacement of all `.jarand*.JAR` files in the specified directory. So the following line:

java -cp /tmp/app/*:/tmp/myJar.jar com.nullhaus.MyApp

will add the /tmp/myJar.jar to the classpath, as well as all the *.jar and *.JAR files in the /tmp/app directory.

Just remember that classpath never works recursively, so if you want to scan a subdirectory for jars you need to point it explicitly.
Second thing to remember is that the following construct:

java -cp /tmp/app/*.jar com.nullhaus.MyApp

will NOT select all *.jar files in the directory. Instead it will look for a file named “*.jar” within the /tmp/app directory!

More reading: JSE 6 Documentation