N00b hacking - java code

Hello,

I am trying to simplify the connection to server code as much as possible. I keep getting errors. Errors in RED.

Code:

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

public class connector {

ConnectionConfiguration config = new ConnectionConfiguration(“mydomain.com”,5222,“mydomain.com”);

XMPPConnection connection = new XMPPConnection(config);

connection.connect(); // Syntax error on token “connect”, Identifier expected after this token

connection.login(“username”,“password”); //Syntax error on tokens, delete these tokens

}

What is the simplist code that I can write that will simply connect me to my jabber server and nothing more? Thanks.

actually the code snipped you provided seems to be the easiest and shortest way to connect to a xmpp server.

the problem you might have is that connect() and login() throw XMPPExcetion that must be caught.

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

public class start {

public static void main(String[] args) {

ConnectionConfiguration conf = new ConnectionConfiguration(“jabber.server”, 5222);

XMPPConnection connection = new XMPPConnection(conf);

try {

connection.connect();

connection.login(“username”, “password”);

} catch (XMPPException e) {

e.printStackTrace();

} finally {

connection.disconnect();

}

}

^Thanks, this works!.