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

假如想象 提交于 2019-11-27 07:55:12

问题


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!


回答1:


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.




回答2:


You need to set ClassPath in the JAR manifest.



来源:https://stackoverflow.com/questions/3436852/getting-a-java-lang-classnotfoundexception-even-though-ive-specified-the-correc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!