Wierd jar problem, because of certain smack classes

Hi.

I have my Jabber client, which is working very well. I want to compile it into a executable jar file, so the client can be run from outside eclipse.

When i compile it, and the jar file is done, i double click it, and nothing happens. The process is quickly starting up, and then closing.

Ive spent hours, figuring out what the problem could be, trying to exclude some classes and so on.

And the conclusion is this:

The class ConnectFunction, has 3 methods, with 3 strings, which make this problem occur. The 3 classes are and the 3 strings are:

ConnectFunction()


connection = new XMPPConnection(SERVER_IP);

public void getRoster(String username)


roster.addRosterListener(new RosterListener()

{

lots of presence code

}

private void startListener()


connection.addPacketListener(myListener, filter);

So if i have my hole complete client, and remove these 3 lines from the classes (including the presence code in the getroster), the jar starts, and the gui shows. The program, of course, doesent work.

Does any of you know why these lines can ruin the application? Because of the connection = new XMPPConnection(SERVER_IP);, I thought it might could be because of security reasons in java. But the other lines arent even initialized when the program starts (the connection is though).

Really hope you can help!

Thanks alot.

/Farsen

— UPDATE -


Ive may be on the right track. Ive managed to get the “Exception in thread “main” java.lang.NoClassDefFoundError: /org/jivesoftware/smack/packetlistener at chatstart.main blabla”

when i run the jar

So maybe it is a classpath error? Im using eclipse, and the classpath/build path seems fine.

Hope somebody can help…

Thanks alot!

Message was edited by: Farsen

Read what I wrote here http://www.igniterealtime.org/forum/thread.jspa?threadID=26944&tstart=0 and in addition to that since you are trying to make an executable jar file the way to add things to your classpath is to add a Class-Path entry to your mainfest file like so

Class-Path: smack.jar

Note the the jar files can not be inside of your jar file unless you get in to writing custom class loaders.

I found out.

Thanks alot!!