9

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

4
  • possible duplicate of Using wildcard for classpath? May 30, 2011 at 17:50
  • read this article on setting the classpath. Wildcards work, simply mention <dir_name>/*. For the current directory, include the '.' character. May 30, 2011 at 17:51
  • @VineetReynolds: (for duplicate) Nope, mine is more specific.
    – CharlesB
    May 30, 2011 at 17:56
  • @VineetReynolds: Yep, I had read the article.
    – CharlesB
    May 30, 2011 at 18:02

1 Answer 1

5

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.

1
  • Wildcards work fine for me in Windows 7 without quotes: java -cp bin;lib/selenium-jars/*;lib/selenium-jars/libs/* tests.StressWebAppServer
    – LarsH
    Sep 17, 2012 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.