Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java classpath wildcard not working without quotes

Tags:

java

classpath

I have a folder with lots of jar files and a classpath:

-classpath ./classes:./jogamp-all-platforms/jar/*

But it doesn't find the package. Just to make sure that I have the resource in question I manually find the jar that contains it and change the classpath to:

-classpath ./classes:./jogamp-all-platforms/jar/jogl-all.jar

And now it isn't complaining about not finding a package.

like image 499
Dude Dawg Avatar asked Oct 30 '12 18:10

Dude Dawg


2 Answers

Under Debian I had to put quotations marks just around the wildcard for this to work: "*"

Then the compile command becomes:

javac -cp ~/my\ stuff/Java/"*" test.java

I'm using JDK, JRE 8.

like image 93
gentmatt Avatar answered Oct 18 '22 10:10

gentmatt


I think you need to use ; as path separator after ./classes as below:

 -classpath ./classes;./jogamp-all-platforms/jar/*

Also please note:

Subdirectories are not searched recursively. For example, jogamp-all-platforms/jar/* looks for JAR/Class files only in jogamp-all-platforms/jar, not in jogamp-all-platforms/jar/abcd, jogamp-all-platforms/jar/efc, etc.

By doing -classpath ./classes:./jogamp-all-platforms/jar/*, it looks of all the JARs in jogamp-all-platforms/jar folder only.

For more details, please refer the documentation here- Wildcards in classpath.

like image 36
Yogendra Singh Avatar answered Oct 18 '22 11:10

Yogendra Singh