I have some jars in the current directory, all needing to be in the class path, so I want to use the wildcards convention for classpath. The command line is:
java.exe -classpath * org.python.util.jython args
However I get this error
Exception in thread "main" java.lang.NoClassDefFoundError: G:/repo/builds/jars/edu_mines_jtk/jar
Caused by: java.lang.ClassNotFoundException: G:.repo.builds.jars.edu_mines_jtk.jar
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: G:/repo/builds/jars/edu_mines_jtk.jar. Program will exit.
If I manually expand the wildcard, with
java.exe -classpath edu_mines_jtk.jar;ij.jar;jython.jar;more-jars org.python.util.jython [args]
Then it works as expected.
What's wrong with my wildcards?
JRE 1.6.25 for Win7 64 bit
I found it, under Windows quotes around the wildcarded classpath are required.
But not required if you specify jars explicitly, explaining why the second command works.
Weird.
来源:https://stackoverflow.com/questions/6179281/calling-java-with-wildcards-in-classpath-fails