2013-08-26 65 views
0

我使用jacob加載系統證書。它的工作很好,當我使用public static void main(String args[])運行代碼或者說簡單的Java程序,但是當我嘗試使用小程序我得到錯誤的後續運行代碼...com.jacob.com.ComFailException:無法共同創建對象

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程序,但同時使用小程序相同的代碼給出錯誤。

在使用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

你看看小應用程序例如雅各來了嗎? Download的來源,並看看它。你可以在: samples\com\jacob\samples\applet。找到它那裏還有一個readme.txt文件。它描述了使jacob在applet中運行的所有步驟。總之:

  1. 指定JNLP文件的本地庫(與nativelib HREF)
  2. 標誌所有罐子(由於Java 1.7.0_17這已成爲強制性的)
  3. 設置的權限/使用策略文件