htmlunit开启activeX
webClient.getOptions().setActiveXNative(true);
会报错:
com.jacob.com.ComFailException: Can't find moniker
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)
需要用到jacob.jar
项目目前导入1.19,JDK1.8,64位WIN10。
尝试过网上的更换32位JDK已及1.7JDK以及各个版本的jacob。
IE中的activeX能够正常使用,并且官网htmlunit官网示例中
final ActiveXComponent activeXComponent = new ActiveXComponent("InternetExplorer.Application");
final boolean busy = activeXComponent.getProperty("Busy").getBoolean();
System.out.println(busy);
也无问题。
但是在java代码中就是会报错Can't find moniker,网上也没查出个所以然来。
- 初步判断跟htmlunit无关(错误信息是jacob初始化的时候的错误)
- 跟jacob也无关(因为并不是所有的clsid在初始化时都会报错)
怀疑是dll的问题,但是个人并不懂dll,不清楚在什么情况下会导致jacob报错Can't find moniker。也尝试过Regsvr32注册,失败了。VC,VB的运行库也都有。也弄了个32位的Win10实验,也失败。反正网上各种都可能性的言论都试过了。
如果是因为dll编写的原因导致的,麻烦有大佬能告知一下是什么情况下会导致这个问题。
真心求教怎么解决这问题。。。脑壳痛啊