XMPPException - NoClassDefFoundError while executing

Code:

import org.jivesoftware.smack.*;

public class Jabber

{

XMPPConnection connection;

public void Connect(String host, int port, String login, String pass)

{

try

{

connection = new XMPPConnection(host, port);

connection.login(login, pass);

}

catch(XMPPException e)

{

System.out.println(“Exception”);

}

}

public static void main(String[] args)

{

Jabber jabber = new Jabber();

jabber.Connect(“chrome.pl”, 5222, “login”, “pass”);

System.out.println("…");

jabber.connection.close();

}

}

/code

Error:

E:_java>javac -classpath smack/smack.jar Jabber.java

E:_java>java Jabber

Exception in thread “main” java.lang.NoClassDefFoundError: org/jivesoftware/smac

k/XMPPException

/code

%CLASSPATH% :

E:_java>set CLASSPATH

CLASSPATH=.;C:\Program Files\Java\jre1.5.0_06\lib\ext\QTJava.zip

/code

What’'s the problem with it?

Hi Mewp,

in my opinion it’'s not a Smack problem but one which sits in front of the computer

You add a smack.jar to the classpath while compiling but not while executing. Try “java -classpath smack/smack.jar Jabber”

LG

lol, thx, working :stuck_out_tongue:

but why it’‘s error with XMPPException, not with XMPPConnection ?(sry, i’'m a newb in java)

Hi,

this is a much more complicated question, we should look at the classloader with “java -verbose:class …”. I assume that the classloader wants to load the XMPPException before XMPPConnection and so you get this error. It’'s maybe because of the “catch XMPPException”, you could try it with “catch Exception” or “main() throws Exception” if you want to look further into this.

LG