我正在使用jacob
来加载系统证书。当我使用public static void main(String args[])
运行代码或说简单的Java程序时,它工作正常,但当我尝试使用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
用于applet时,我是否有任何具体的事情要记在心里。我正在使用jacob-1.17
ActiveXComponent comp=new ActiveXComponent("Encryption.LoadCertificate");
并在互联网上的某个地方找到......
activeXObj = (ActiveXComponent)AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
return new ActiveXComponent(SystemWrapper.currentObjName);
}
});
答案 0 :(得分:0)
您是否看过雅各布的applet示例? Download来源并查看它。您可以在以下位置找到它:
samples\com\jacob\samples\applet
。那里还有一个readme.txt文件。它描述了使jacob在applet中运行所涉及的所有步骤。简而言之: