noobcoder
noobcoder

Reputation: 6651

Why does this javac command not work?

javac -cp .:gson-2.3.1.jar:commons-io-2.4.jar File.java

The above command works on one of my linux machines. However it does not work on another one even though it is the same distro! (Debian)

The shell does not throw any errors of any sort which suggests it is finding the .jar files just fine, however the java compiler throws errors wherever I have used the .jar files in my code e.g. "the import org.apache cannot be resolved" , "the import org.gson cannot be resolved" etc.

The Java file and both the required .jar files are in the current directory. I am using Java 1.6. What is going wrong here?

Upvotes: 1

Views: 708

Answers (1)

noobcoder
noobcoder

Reputation: 6651

FIXED. Out of desperation I changed javac -cp to javac -classpath and it magically worked. Always pays to be explicit!

Upvotes: 3

Related Questions