Adam Matan
Adam Matan

Reputation: 136221

Java commands runs on bash, fails on zsh

Consider the following command which runs flawlessly using bash:

java -classpath bin:lib/* FunctionalTests.TestRunner

The classes are in bin, jars are in lib, main() is in bin/FunctionalTests/TestRunner:

.
├── bin
├── lib
│   ├── commons-collections-3.2.1.jar
│   ├── commons-httpclient-3.1.jar
│   ├── commons-io-2.1.jar
│   ├── commons-lang-2.4.jar
│   ├── commons-logging-1.1.1.jar
│   └── ...
└── src

When the same command runs with zsh, the output is:

zsh: no matches found: ./bin:./lib/*

Any ideas?

Upvotes: 3

Views: 6831

Answers (2)

Teg
Teg

Reputation: 1302

Try to use something like this to add every .jar in the classpath:

CP=bin
for i in lib/*.jar
do
  CP=$CP:${i}               
done
java -classpath $CP FunctionalTests.TestRunner

Upvotes: -1

Adam Matan
Adam Matan

Reputation: 136221

It boils down to another pair of quotes:

java -classpath "bin:lib/*" FunctionalTests.TestRunner

Hope it helps someone in the future.

Upvotes: 19

Related Questions