java.lang.NoClassDefFoundError when running JMS consumer
23,283
-cp
option of java
command should be placed before the class name:
java -cp .;activemq-all-5.3.2.jar consumer1
Otherwise it's treated as an argument of your main
method, not as java
's argument. Also note that if you specify classpath with -cp
option, you need to include the current directory in order to run .class
files from it.
Related videos on Youtube
Author by
Jeune
I'm an aspiring software architect. I develop in Java and I want to learn Python. Outside coding, I play futbol (soccer) and cook Asian dishes.
Updated on October 16, 2020Comments
-
Jeune over 3 years
I am trying to run a class I made however I get this error:
Exception in thread "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:
java consumer1 -cp activemq-all-5.3.2.jar
-
Martijn Verburg over 13 yearsIs activemq-all-5.3.2.jar in the same directory as consumer1?
-
Martijn Verburg over 13 yearsHave you checked the activemq-all-5.3.2.jar so make sure it's got that class? (might be a corrupt artifact) you can execute 'jar tvf activemq-all-5.3.2.jar' to see.
-
Jeune over 13 yearsI checked it by expanding the jar in eclipse. It is there.
-
-
Jeune over 13 yearsI did the -cp option before the class name before. The only difference this time is that I added this ".;" what does that mean? To include in the classpath everything in the current folder? I don't understand why I need to do that when there are no dependencies in the current folder.
-
axtavt over 13 years@Jeune: When you run
java consumer1
,consumer1
is a name of class in the classpath. By default classpath is a current directory, so this command will runconsumer1.class
from it. When you use-cp
option, you override the default classpath, so you need to specify the current folder explicitly in order to runconsumer1.class
from it. -
Prinzhorn over 11 yearsNOTE: On Linux you need
:
as a separator instead of;
. Drove me nuts.