Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a java.lang.ClassNotFoundException even though i've specified the correct jar with -cp

java.lang.ClassNotFoundException: com.hazelcast.core.Hazelcast

This bit is strange though, because i've added hazelcast-1.8.5.jar to the classpath when i'm running java:

java -cp hazelcast-1.8.5.jar -jar myapp.jar

So i cannot understand why i'm getting the ClassNotFoundException, when the hazelcast jar is well and truly present, and specified in the command line. Any ideas please?

By the way, hazelcast is pretty fricking sweet!

like image 329
Chris Avatar asked Aug 09 '10 01:08

Chris


2 Answers

From the -jar option docs:
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

like image 163
Nikita Rybak Avatar answered Oct 26 '22 01:10

Nikita Rybak


You need to set ClassPath in the JAR manifest.

like image 22
duffymo Avatar answered Oct 26 '22 01:10

duffymo