JSkype error sending message
I'm trying to run the following code but unfortunately facing Error problems
package jskypeexample;
// import the JSkype packages
import net.lamot.java.jskype.general.AbstractMessenger;
import net.lamot.java.jskype.general.MessageListenerInterface;
import net.lamot.java.jskype.windows.Messenger;
import java.lang.Thread;
import java.lang.Exception;
/**
*
* @author swhite
*/
public class JSkypeExample implements MessageListenerInterface {
// create a messenger which we'll use for sending messages
private AbstractMessenger ms开发者_运维问答gr = null;
/** Creates a new instance of JSkypeExample */
public JSkypeExample() {
msgr = new Messenger();
msgr.addListener(this);
msgr.initialize();
try {
// This number may vary on your system depending on the amount
// of time required to initialize the msgr.
Thread.sleep(1000);
// send the Skype API text command
msgr.sendMessage("Message seanmwhite Hello from UI Student");
msgr.sendMessage("SEARCH FRIENDS");
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new JSkypeExample();
}
public void onMessageReceived(String str) {
// This is where you will handle all strings that are returned.
System.out.println(str);
}
}
But when I comment the following lines then it runs well.
msgr.initialize();
msgr.sendMessage("Message seanmwhite Hello from UI Student");
msgr.sendMessage("SEARCH FRIENDS");
But I have to send commands to receive the response. Actually I'm using JSkype Api (open source api from java ).
You have to set your boolean value that your initilaze function is returning to true or catch that execpetion if it is false.
精彩评论