0

次のコードを実行しようとしていますが、残念ながらエラーの問題に直面しています

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 msgr = 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);
   }

 }

しかし、次の行にコメントすると、うまく動作します。

 msgr.initialize(); 
 msgr.sendMessage("Message seanmwhite Hello from UI Student");
 msgr.sendMessage("SEARCH FRIENDS");

しかし、応答を受信するにはコマンドを送信する必要があります。実際、私は JSkype Api (java のオープンソース api) を使用しています。

4

1 に答える 1

0

initilaze 関数が返すブール値を true に設定するか、false の場合はその実行をキャッチする必要があります。

于 2010-09-29T08:28:54.097 に答える