什么是正确的com.skype。*使用Linux?

时间:2014-06-29 21:30:54

标签: java linux java-native-interface skype

在Linux(Ubuntu 14.04)上,此代码在打印“获取联系人列表”后挂起:

package skype;

import com.skype.ContactList;
import com.skype.Friend;
import com.skype.Skype;
import com.skype.SkypeException;

public class ContactLister {

    public void getAllFriend() throws SkypeException, InterruptedException {
        System.out.println("starting...");
        ContactList contactList = Skype.getContactList();
        System.out.println("got contact list " + contactList.toString());
        Friend friends[] = contactList.getAllFriends();
        System.out.println("got friends");
        System.out.println(friends.length);
        for (Friend friend : friends) {
            System.out.println("Friend ID :" + friend.getId());
            Thread.sleep(100);
        }
    }

    public static void main(String[] args) throws SkypeException, InterruptedException, SkypeException {
        new ContactLister().getAllFriend();
    }
}

检查库,com.skype.connector似乎使用JNI与Skype连接。至少对我而言,这种联系似乎永远不会发生。

甚至可以使用它连接到Skype吗?我怎么知道为什么它(显然)没有连接?

thufir@dur:~$ 
thufir@dur:~$ java -jar NetBeansProjects/Skype/dist/Skype.jar 
starting...
got contact list com.skype.ContactList@1d7ad1c
^Cthufir@dur:~$ 
thufir@dur:~$ skype --version
Skype 4.2.0.11
Copyright (c) 2004-2013, Skype
thufir@dur:~$ 

1 个答案:

答案 0 :(得分:0)

虽然这有效:

package net.bounceme.dur.skype;

import java.io.*;

public class SkypeEchoTest {

    public static void main(String args[]) throws IOException {
        String s = null;
        Process p = Runtime.getRuntime().exec("skype --callto echo123");
        BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
        System.out.println("Here is the standard output of the command:\n");
        while ((s = stdInput.readLine()) != null) {
            System.out.println(s);
        }
        System.exit(0);
    }
}

它并没有让人感觉到哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇因子。此外,它只适用于Linux,不知道它在Windows中如何工作。 (您必须首先运行Skype,然后执行字节码。)