我正在使用jacob
加载系统证书。当我使用或说简单的 Java 程序运行代码时,它工作正常,public static void main(String args[])
但是当我尝试使用 Applet 运行代码时,我收到如下错误...
com.jacob.com.ComFailException: Can't co-create object
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 com.digicorp.root.SystemWrapper$1.run(SystemWrapper.java:23)
at java.security.AccessController.doPrivileged(Native Method)
at com.digicorp.root.SystemWrapper.<init>(SystemWrapper.java:19)
at com.digicorp.applet.DigitalCertificateApplet.ActiveXObject(DigitalCertificateApplet.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.Trampoline.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass$MethodInfo.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass$MemberBundle.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass.invoke0(Unknown Source)
at sun.plugin2.liveconnect.JavaClass.invoke(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$DefaultInvocationDelegate.invoke(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo.doObjectOp(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我还使用http://netheadaches.wordpress.com/2012/04/22/jacob-cant-co-create-object/来解决上述问题。它解决了简单的 java 程序,但在使用 applet 时相同的代码给出了错误。
jacob
在使用小程序时,我有什么特别的事情要记住吗?我在用着jacob-1.17
ActiveXComponent comp=new ActiveXComponent("Encryption.LoadCertificate");
并在互联网上的某个地方找到...
activeXObj = (ActiveXComponent)AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
return new ActiveXComponent(SystemWrapper.currentObjName);
}
});