Sorry for such a long post, Im still trying to educate myself and thought if you guys have all the necessary info itll go smoother..
Trying to load the sample from ...
Abhijeet Maharana » Writing a gTalk (Jabber/XMPP) client in Java
getting the following errors...
generics are not supported in -source 1.3 (try -source 1.5 to enable generics)
and..
for-each loops are not supported in -source 1.3 (try -source 1.5 to enable for-each loops)
output from the debugger
Building ChatClient
C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin\rapc.exe -quiet import="..\..\..\..\..\Program Files\Research In Motion\BlackBerry JDE 4.3.0\lib\net_rim_api.jar" codename=ChatClient\ChatClient ChatClient\ChatClient.rapc warnkey=0x52424200;0x52435200;0x52525400 "C:\Documents and Settings\jbm\Desktop\jbmJDE\JBM\ChatClient\CC\Chat Client.java"
C:\Documents and Settings\jbm\Desktop\jbmJDE\JBM\ChatClient\CC\Chat Client.java:37: generics are not supported in -source 1.3
(try -source 1.5 to enable generics)
Collection<RosterEntry> entries = roster.getEntries();
^
C:\Documents and Settings\jbm\Desktop\jbmJDE\JBM\ChatClient\CC\Chat Client.java:40: for-each loops are not supported in -source 1.3
(try -source 1.5 to enable for-each loops)
for(RosterEntry r:entries)
^
2 errors
Error!: Error: java compiler failed: javac -source 1.3 -target 1.1 -g -O -d C:\DOCUME~1\jbm\LOCALS~1\Temp\rapc_58fe1e24.dir -bootcla ...
Error while building project
Here is the source..
import java.util.*;
import java.io.*;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
public class ChatClient implements MessageListener
{
XMPPConnection connection;
public void login(String userName, String password) throws XMPPException
{
ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
connection = new XMPPConnection(config);
connection.connect();
connection.login(userName, password);
}
public void sendMessage(String message, String to) throws XMPPException
{
Chat chat = connection.getChatManager().createChat(to, this);
chat.sendMessage(message);
}
public void displayBuddyList()
{
Roster roster = connection.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
System.out.println("\n\n" + entries.size() + " buddy(ies):");
for(RosterEntry r:entries)
{
System.out.println(r.getUser());
}
}
public void disconnect()
{
connection.disconnect();
}
public void processMessage(Chat chat, Message message)
{
if(message.getType() == Message.Type.chat)
System.out.println(chat.getParticipant() + " says: " + message.getBody());
}
public static void main(String args[]) throws XMPPException, IOException
{
// declare variables
ChatClient c = new ChatClient();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String msg;
// turn on the enhanced debugger
XMPPConnection.DEBUG_ENABLED = true;
// provide your login information here
c.login("madnesstestuser", "password");
c.displayBuddyList();
System.out.println("-----");
System.out.println("Enter your message in the console.");
System.out.println("All messages will be sent to abhijeet.maharana");
System.out.println("-----\n");
while( !(msg=br.readLine()).equals("bye"))
{
// your buddy's gmail address goes here
c.sendMessage(msg, "abhijeet.maharana@gmail.com");
}
c.disconnect();
System.exit(0);
}
}