jacob下载包含jar包和src
下载
http://sourceforge.net/projects/jacob-project/files/
解压后获得3个文件
jacob.jar
jacob-1.17-x64.dll
jacob-1.17-x86.dll
jacob.jar 放到项目的lib目录
win7
jacob-1.17-x64.dll 放到C:\Windows\System32
jacob-1.17-x86.dll 放到C:\Windows\SysWOW64
win7就是这么设计的, System32放64位dll,SysWOW64放32位dll,是不是很诡异。
还要注意的是,32位JDK只能加载32位DLL,64位JDK只能加载64位DLL,不能互相兼容。
还可以把jacob-1.17-x86.dll 放到jdk/jre/bin下,我选的这个
若找不到jacob.dll,会报如下错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jacob-1.17-x86 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:184)
at com.jacob.com.JacobObject.<clinit>(JacobObject.java:107)
at MsWordEdit.<init>(MsWordEdit.java:25)
at MsWordEdit.main(MsWordEdit.java:642)
如果不清楚java.library.path,输出一下即可。代码如下
System.out.println(System.getProperty("java.library.path"));
示例:
Java操作Microsoft Word之jacob
http://xiaoduan.blog.51cto.com/502137/136692/
使用Jacob输出word文档
上一篇: jacob操作office分享