5

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!

Chris
  • 39,719
  • 45
  • 189
  • 235
  • Hang on, is it something to do with this: http://stackoverflow.com/questions/2910115/include-external-jar-when-running-java-jar – Chris Aug 09 '10 at 01:43

2 Answers2

8

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.

Nikita Rybak
  • 67,365
  • 22
  • 157
  • 181
  • Ok, I see you figured it out yourself – Nikita Rybak Aug 09 '10 at 01:47
  • Yes, i created a manifest file with the line "Class-Path: lib/hazelcast-1.8.5.jar" and compiled my jar with "jar cfm reconciler.jar reconciler.manifest reconciler/" then ran it with "java -jar myapp.jar". Thanks for the help. – Chris Aug 09 '10 at 01:50
4

You need to set ClassPath in the JAR manifest.

duffymo
  • 305,152
  • 44
  • 369
  • 561