关于jacob中出现的问题(上传文件)
1) 把jacob.dll放入 Java\jdk1.5.0_06\jre\bin目录下.
2) 把jacob.jar放入 Java\jdk1.5.0_06\jre\lib\ext 目录下.
3) 运行*.java即可编译通过.
注明:
1)配置后不需要再进行什么环境变量path,classpath的设置.
2)jdk版本高于1.4.2就不会影响程序,低于其以下没测试.
常见错误解释:
------------
1、找不到jacob.dll,配置路径问题(确认jacob.dll配置正确)
Exception in thread "……" java.lang.UnsatisfiedLinkError: no jacob in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at com.jacob.com.Dispatch.<clinit>(Dispatch.java:36)
……
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
------------
2、找不到资源文件,资源文件路径问题(查看程序中资源文件路径的设置,并检查资源文件的存放路径)
Exception in thread "……" com.jacob.com.ComFailException: Invoke of: Open
Source: Microsoft Word
Description: RCHITECTURE=x86
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:890)
at com.jacob.com.Dispatch.callN(Dispatch.java:526)
at com.jacob.com.Dispatch.call(Dispatch.java:606)
at WordControl.openDocument(Test06_08_01.java:3027)
……
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
------------
3、jacob.dll或jacob.jar对应版本错误
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: Documents
Description: An unknown COM error has occured.
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.activeX.ActiveXComponent.getProperty(ActiveXComponent.java)
at com.perlong.poa.common.dao.sqlserver.WordToHtml.change(WordToHtml.java:73)
at com.perlong.poa.common.dao.sqlserver.WordToHtml.main(WordToHtml.java:121)
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: Quit
Description: An unknown COM error has occured.
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.activeX.ActiveXComponent.invoke(ActiveXComponent.java)
at com.perlong.poa.common.dao.sqlserver.WordToHtml.change(WordToHtml.java:92)
at com.perlong.poa.common.dao.sqlserver.WordToHtml.main(WordToHtml.java:121)
Exception in thread "main"
相关:
------------
jacob 就是 JAVA-COM Bridge的缩写,它是在java与微软的com组件之间的桥梁,通过使用jacob自带的dll动态链接库通过JNI的方式实现了在sun java平台上的程序对com调用。