谢谢大家
G4J这个开源jar包最终放弃,采用了Linker.jar。
缺点是只能取到gtalk的联系人。 ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com"); XMPPConnection connection = new XMPPConnection(config);
try {
connection.connect();
} catch (XMPPException e) {
e.printStackTrace();
}
if (connection.isConnected()) {
// connect failed
try {
connection.login(name, passwd);
} catch (XMPPException e) {
} if (connection.isAuthenticated()) {
System.out.println("login sucess");
} else {
System.out.println("login failed");
throw new ServerAppException(ErrorCode.DATABASE_ACCOUNT_NULL, "login failed");
}
} else {
System.out.println("connect failed");
throw new ServerAppException(ErrorCode.DATABASE_ACCOUNT_NULL, "login failed");
}