skype4java :

skype4java 地址:

http://skype.sourceforge.jp/index.php?Skype%20API%20For%20Java%20%28English%29

使用jni封装skype com+接口

但其

Win32Connector::protected void initializeImpl() 方法有些问题,其意图是如果没又找到skype库就从包里面解压缩skype.dll到临时文件夹下,但是我不知道为什么作者要用zip遍历,而不是使用类加载器获得资源来解压缩。

我做的修改:

try {
            System.loadLibrary("skype");
        } catch(Throwable e) {
            try {
                if(!ConnectorUtils.checkLibraryInPath(LIBFILENAME)) {
                    String dllPath;
                    String tmpDir = System.getProperty("java.io.tmpdir");
                    if(!tmpDir.endsWith("" + File.separatorChar)) {
                        tmpDir = tmpDir + File.separatorChar;
                    }
                    dllPath = tmpDir + LIBFILENAME;
                    File dll = new File(dllPath);
                    if(!dll.exists()) {
extractDll(dll);
                        if(!dll.exists()) {
                            throw new RuntimeException("can't load " + dllPath);
                        }
                    }
                    System.load(dllPath);
                }
            } catch(Exception e1) {
                throw new RuntimeException(e1);
            }
        }

private void extractDll(File destFile) {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream input = loader.getResourceAsStream(LIBFILENAME);
        FileOutputStream output = null;
        try {
            output = new FileOutputStream(destFile);
            byte[] buffer = new byte[1024 * 4];
            long count = 0;
            int n = 0;
            while(-1 != (n = input.read(buffer))) {
                output.write(buffer, 0, n);
                count += n;
            }
        } catch(Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if(null != input) {
                    input.close();
                }
            } catch(IOException e) {
            }
            try {
                if(null != output) {
                    output.close();
                }
            } catch(IOException e) {
            }
        }
    }

需要

winp.jar 检查是否running

swt.jar 借用OS基础功能


Total views.

© 2013 - 2018. All rights reserved.

Powered by Hydejack v6.6.1