My environment is Java 8, on Windows 7 - 64 bit. So here's my requirement and procedures I followed java:java version "1.8.0_131" 32 bit jacob:jacob-1.18-x86.dll &jacob.jar
i use the eclipse to run the following code .it works well.
import com.jacob.com.*;
import com.jacob.activeX.*;
public class DispatchTest {
public static void main(String[] args) {
ActiveXComponent xl = new ActiveXComponent("Execl.Application");
Dispatch xlo = (Dispatch)(xl.getObject());
try {
System.out.println("version="+xl.getProperty("Version"));
System.out.println("version="+Dispatch.get(xlo, "Version"));
} catch (Exception e) {
e.printStackTrace();
} finally {
xl.invoke("Quit", new Variant[] {});
}
}
}
when i try to use the third party dll and i meet the following execption:
import com.jacob.com.*;
import com.jacob.activeX.*;
public class DispatchTest {
public static void main(String[] args) {
ActiveXComponent xl = new ActiveXComponent("ProjectParser.1");
Dispatch xlo = (Dispatch)(xl.getObject());
try {
System.out.println("version="+xl.getProperty("Version"));
System.out.println("version="+Dispatch.get(xlo, "Version"));
} catch (Exception e) {
e.printStackTrace();
} finally {
xl.invoke("Quit", new Variant[] {});
}
}
}
Exception in thread "main" com.jacob.com.ComFailException: Can't QI object for IDispatch
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at DispatchTest.main(DispatchTest.java:5)
https://github.com/joval/jacob/blob/master/jni/Dispatch.cpp
can anyone please guide me to the solution?