Roster Problem

When I use the example code for retrieving a roster I get and error

I use this code:

//Roster Listener

final Roster roster = jconn.getRoster();

roster.addRosterListener( new RosterListener() {

public void rosterModified() {

// Ignore event for this example.

}

public void presenceChanged(String user) {

// If the presence is unavailable then “null” will be printed,

// which is fine for this example.

logMessage("Presence changed: " + roster.getPresence(user));

}

});

and get the following compile errors

/development/uib/uibJabberBean.java:398: expected

roster.addRosterListener( new RosterListener() {

^

/development/uib/uibJabberBean.java:398: package roster does not exist

roster.addRosterListener( new RosterListener() {

^

Note: Some input files use or override a deprecated API.

Note: Recompile with -deprecation for details.

2 errors

Help would be appreciated

Thanks

Colin,

From the errors that you paste in your post I can think of two possible reasons.

  1. The offending statement is not inside a method, so

the compiler cannot understand it

  1. There is a problem with the closing brace in your code

If you want you can post the whole class code so I can take it a look but first make sure that it’'s not very long.

– Gato

Thanks for that one

I hadnt realised that that particular listener had to be inside a function.

All sorted, thanks again