用jacob时错误。

dylsz 2004-08-26 09:16:29
在网上找了这样一个程序:
import java.io.File;
import com.jacob.com.*;
import com.jacob.activeX.*;
/**
* Title: pdf extraction
* Description: email:chris@matrix.org.cn
* Copyright: Matrix Copyright (c) 2003
* Company: Matrix.org.cn
* @author chris
* @version 1.0,who use this example pls remain the declare
*/
public class FileExtracter{
public static void main(String[] args) {
ActiveXComponent component = new ActiveXComponent("Word.Application");
String inFile = "c:\\test.doc";
String tpFile = "c:\\temp.htm";
String otFile = "c:\\temp.xml";
boolean flag = false;
try {
component.setProperty("Visible", new Variant(false));
Object wordacc = component.getProperty("document.").toDispatch();
Object wordfile = Dispatch.invoke(wordacc,"Open", Dispatch.Method,
new Object[]{inFile,new Variant(false), new Variant(true)},
new int[1] ).toDispatch();
Dispatch.invoke(wordfile,"SaveAs", Dispatch.Method, new Object[]{tpFile,new Variant(8)}, new int[1]);
Variant f = new Variant(false);
Dispatch.call(wordfile, "Close", f);
flag = true;
} catch (Exception e) {
e.printStackTrace();
} finally {
component.invoke("Quit", new Variant[] {});
}
}
}

编译时发生下面这样的错误:
F:\java>javac Test.java

F:\java>java Test
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jacob in java.libr
ary.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at com.jacob.com.Dispatch.<clinit>(Dispatch.java)
at Test.main(Test.java:14)

请问这是怎么回事?
...全文
178 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingxyz 2005-01-04
  • 打赏
  • 举报
回复
1.加载JACOB的包
2.把JACOB.DLL放到系统目录下面(比如C:\WINDOWS\SYSTEM32\目录下面)
tonee 2005-01-04
  • 打赏
  • 举报
回复
jacob.dll放到你设置的环境变量的path指定的任何一个目录下就可以了
疯癫行者 2004-11-25
  • 打赏
  • 举报
回复
不好意思,更正一下:
其中somepath替换成,jacob.dll所在的目录。
疯癫行者 2004-11-24
  • 打赏
  • 举报
回复
运行时应该这样:
F:\java>java -Djava.library.path=somepath Test
其中somepath替换成,jacob所在的目录。
zmybest 2004-08-26
  • 打赏
  • 举报
回复
你的jacob包放到哪个目录里了?是否设置了jacob包的classpath
dylsz 2004-08-26
  • 打赏
  • 举报
回复
加了阿.
zhigangsun 2004-08-26
  • 打赏
  • 举报
回复
你加载jacob包了么

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧