tags:

views:

25

answers:

1

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

+1  A: 

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

axtavt
I 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.
Jeune
@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 run `consumer1.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 run `consumer1.class` from it.
axtavt
@axtavt thanks! that cleared things a lot! :) +1
Jeune