BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-28-2008, 01:31 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2006
Model: 8300
Carrier: att
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default SMACK API - need help w sample ChatClient

Please Login to Remove!

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);
}
}
Offline  
Old 04-28-2008, 05:47 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2006
Model: 8300
Carrier: att
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default another question..

in case someone can explain ho to fix te last error..

I commented the lines out and now Im getting errors relating to the importing of the SMACK API. Can someone tell me how to import external API's? I tried placing the .jar's into the \bin folder and that doesnt seem to work.. so is there a proper way to get all the api's in the correct location?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.