Reputation: 1774
I have a simple, single file java program that relies on a single static jar. The java code and the jar reside in the same directory. For this one-off solution I don't want to bring in the weight of ant or maven, and just want to compile it directly.
On my dev box, the following compiles and runs my code fine:
javac -cp ".;dependency.jar" File.java
java -cp ".;dependency.jar" File
However, on my test box, the java
command fails, and I get the following output:
Error: Could not find or load main class File
If I change my classpath arg to -cp "."
I get the following output:
Exception in thread "main" java.lang.ClassNotFoundException: dependency
My dev box is 64-bit Windows/Cygwin and java version 1.7.0_55
. My test box is 64-bit Linux and java version 1.7.0_45
.
What is going wrong on my test box?
Upvotes: 2
Views: 68
Reputation: 178253
The classpath separator character is different on Linux (and on Unix) than it is on Windows. It's ;
on Windows, but it's :
on Linux (and Unix).
Try this on Linux:
javac -cp ".:dependency.jar" File.java
java -cp ".:dependency.jar" File
Upvotes: 6