0

我正在使用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);
                }
              });
4

1 回答 1

0

你看过 Jacob 附带的小程序示例吗?下载源代码并查看它。您可以在以下位置找到它: samples\com\jacob\samples\applet。那里还有一个 readme.txt 文件。它描述了使 jacob 在小程序中运行所涉及的所有步骤。简而言之:

  1. 在 jnlp 文件中指定本机库(使用 nativelib href)
  2. 签署所有罐子(从 java 1.7.0_17 开始,这已成为强制性的)
  3. 设置权限/使用策略文件
于 2013-08-27T08:33:54.983 回答