即使我已经用 -cp 指定了正确的 jar,也会得到一个 java.lang.ClassNotFoundException [英] Getting a java.lang.ClassNotFoundException even though i've specified the correct jar with -cp
问题描述
java.lang.ClassNotFoundException: com.hazelcast.core.Hazelcast
java.lang.ClassNotFoundException: com.hazelcast.core.Hazelcast
虽然这有点奇怪,因为我在运行 java 时已将 hazelcast-1.8.5.jar 添加到类路径中:
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
所以我不明白为什么我会收到 ClassNotFoundException,当 hazelcast 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?
顺便说一句,Hazelcast 非常可爱!
By the way, hazelcast is pretty fricking sweet!
推荐答案
来自 -jar 选项文档:
使用此选项时,JAR 文件是所有用户类的来源,其他用户类路径设置将被忽略.
这篇关于即使我已经用 -cp 指定了正确的 jar,也会得到一个 java.lang.ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!