2

On Linux (Ubuntu 14.04), this code hangs after "got contact list" is printed:

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();
    }
}

Examining the library, com.skype.connector would seem to use JNI to connect with Skype. At least for me, the connection never seems to occur.

Is it even possible to use this to connect to skype? How do I know why why it's not (apparently) connecting?

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:~$ 
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Thufir
  • 8,216
  • 28
  • 125
  • 273
  • this answer: http://stackoverflow.com/a/2945519/262852 didn't work for me. – Thufir Jun 29 '14 at 21:49
  • I think this is the git repo: https://github.com/lemmy/skype4java it seems dead, new maintainer is requested. – Thufir Jun 29 '14 at 22:07

1 Answers1

0

While this works:

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

It doesn't quite have the "wow" factor. Also, it just works on Linux, not sure how it would work in Windows. (You have to have Skype running first, then execute the bytecode.)

Thufir
  • 8,216
  • 28
  • 125
  • 273
  • Please note Skype4COM is deprecated for all usecases except call recording and Hardware device control. While this code may work currently we make no commitment to its longevity – Allen Smith Jun 30 '14 at 08:04