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