Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError when running JMS consumer

Tags:

java

jms

activemq

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

like image 233
Jeune Avatar asked Oct 15 '10 15:10

Jeune


1 Answers

-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.

like image 107
axtavt Avatar answered Sep 23 '22 21:09

axtavt