运行 JMS 使用者时出现 java.lang.NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3943527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError when running JMS consumer
提问by Jeune
I am trying to run a class I made however I get this error:
我正在尝试运行我制作的课程,但是我收到此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jms/Destination
线程“main”中的异常 java.lang.NoClassDefFoundError: javax/jms/Destination
I don't understand why it's not working even when I include the necessary jars in the classpath:
我不明白为什么即使我在类路径中包含必要的 jars 它也不起作用:
java consumer1 -cp activemq-all-5.3.2.jar
java consumer1 -cp activemq-all-5.3.2.jar
采纳答案by axtavt
-cpoption of javacommand should be placed before the class name:
-cpjava命令的选项应该放在类名之前:
java -cp .;activemq-all-5.3.2.jar consumer1
Otherwise it's treated as an argument of your mainmethod, not as java's argument. Also note that if you specify classpath with -cpoption, you need to include the current directory in order to run .classfiles from it.
否则,它将被视为您的main方法的参数,而不是java' 的参数。另请注意,如果您使用-cp选项指定类路径,则需要包含当前目录才能从中运行.class文件。

