powered by Jive Software

java.lang.NoClassDefFoundError: org/jivesoftware/smack/MessageListener

For some reason i get the error:

java.lang.NoClassDefFoundError: org/jivesoftware/smack/MessageListener

when trying to run my very basic client at the command line. I can get it to compile fine. This problem does not occure when working in my IDE, but can only have one instance running at a time, and therefore would like to get some difference instances working from within shells.

Any help would be greately appreciated.

it looks like smack.jar isn’'t in your runtime classpath. You probably either set it up in your editor and then forgot, or it figured it out for you.

I believe its the same problem i have.

Im using eclipse, and the smack.jar and smackx.jar seems to be in the build path.

So what would the command with classpath definitions be to compile the project from a promt?


There are a couple ways you can take care of this. If you are running java and javac from the command line you can use the -classpath option. For example

java -classpath .;c:\smack.jar MyClass

Please note that you probably want to include “.”, your current working directory, and that depending on your OS you either use colons or semicolons as a seperator.

You can also create a “CLASSPATH” environmental variable. Also be aware the both of these get ignored if you are making and running executable jar files.

The easiest thing to do is just to copy smack.jar and smackx.jar to a directory that will automatically pick them up. This directory is called “lib/ext” and it’'s inside of your jre that is inside your jdk installation directory.

Thanks alot for your reply!

I´ve figured it out meanwhile. I added “Class-Path: smack.jar smackx.jar” to the manifest file. Eclipse didnt do that for me. Now the app requires the smack.jar files in the same folder as it is being executed, so i guess your solution might be a bit better

But thanks alot!

Thanks all.

-cp at the command line did not work but I managed with a lot of playing around to get it to work as a jar (with the manifest file changed as mentioned).