栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

JACOB和JRE 1.7出现UnsatisfiedLinkError

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JACOB和JRE 1.7出现UnsatisfiedLinkError

我找到了一个晒太阳的程序员写的了不起的帖子,解决了我的问题!

public static void addDir(String s) throws IOException {    try {        // This enables the java.library.path to be modified at runtime        // From a Sun engineer at http://forums.sun.com/thread.jspa?threadID=707176        Field field = ClassLoader.class.getDeclaredField("usr_paths");        field.setAccessible(true);        String[] paths = (String[])field.get(null);        for (int i = 0; i < paths.length; i++) { if (s.equals(paths[i])) {     return; }        }        String[] tmp = new String[paths.length+1];        System.arraycopy(paths,0,tmp,0,paths.length);        tmp[paths.length] = s;        field.set(null,tmp);        System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + s);    } catch (IllegalAccessException e) {        throw new IOException("Failed to get permissions to set library path");    } catch (NoSuchFieldException e) {        throw new IOException("Failed to get field handle to set library path");    }}

然后我在使用JACOB方法之前添加了

addDir("C:" + File.separator + "java" + File.separator + "jre7" + File.separator + "lib")

像魅力一样工作。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/407224.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号