Is there a way to include all the jar files within a directory in the classpath?
I\'m trying java -classpath lib/*.jar:. my.package.Program
and it is no
To whom it may concern,
I found this strange behaviour on Windows under an MSYS/MinGW shell.
Works:
$ javac -cp '.;c:\Programs\COMSOL44\plugins\*' Reclaim.java
Doesn't work:
$ javac -cp 'c:\Programs\COMSOL44\plugins\*' Reclaim.java
javac: invalid flag: c:\Programs\COMSOL44\plugins\com.comsol.aco_1.0.0.jar
Usage: javac
I am quite sure that the wildcard is not expanded by the shell, because e.g.
$ echo './*'
./*
(Tried it with another program too, rather than the built-in echo
, with the same result.)
I believe that it's javac
which is trying to expand it, and it behaves differently whether there is a semicolon in the argument or not. First, it may be trying to expand all arguments that look like paths. And only then it would parse them, with -cp
taking only the following token. (Note that com.comsol.aco_1.0.0.jar
is the second JAR in that directory.) That's all a guess.
This is
$ javac -version
javac 1.7.0