Java – com4j wrapper Gen problem
•
Java
I'm trying to use tlbimp-20110320 Jar generates a wrapper for com4j I also tried the same wrong 2008 version Even if I try to run the example in Tut, I will encounter the same error
C:\Users\matthew\Documents\NetBeansProjects\test>"C:\Program Files (x86)\Java\jr e7\bin\java.exe" -jar tlbimp-20110320.jar -o excel -p excel "C:\Program Files (x 86)\Microsoft Office\Office14\EXCEL.EXE" Exception in thread "main" java.lang.NoClassDefFoundError: org/kohsuke/args4j/Cm dLineException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(UnkNown Source) at java.lang.Class.getmethod0(UnkNown Source) at java.lang.Class.getmethod(UnkNown Source) at sun.launcher.LauncherHelper.getMainMethod(UnkNown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(UnkNown Source) Caused by: java.lang.ClassNotFoundException: org.kohsuke.args4j.CmdLineException at java.net.urlclassloader$1.run(UnkNown Source) at java.net.urlclassloader$1.run(UnkNown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.urlclassloader.findClass(UnkNown Source) at java.lang.ClassLoader.loadClass(UnkNown Source) at sun.misc.Launcher$AppClassLoader.loadClass(UnkNown Source) at java.lang.ClassLoader.loadClass(UnkNown Source) ... 6 more
After Iceman provides a link to the required library, I can make it run a little But I had to copy the arg4j content to Tlbimp jar and the com4j content to Tlbimp jar Now I see
C:\Users\matthew\Documents\NetBeansProjects\test>"C:\Program Files (x86)\Java\jr e7\bin\java.exe" -jar tlbimp-20110320.jar -o excel -p excel "C:\Program Files (x 86)\Microsoft Office\Office14\EXCEL.EXE" Generating deFinitions from Excel A referenced type library "Office" is generated into the same package "excel" Unable to handle the type SAVEARRAY(Variant)* method ConnectData interface IRtdServer A referenced type library "VBIDE" is generated into the same package "excel" Exception in thread "main" java.lang.NullPointerException at com4j.tlbimp.driver.Driver$1.resolve(Driver.java:64) at com4j.tlbimp.Generator$LibBinder.<init>(Generator.java:382) at com4j.tlbimp.Generator.getTypeLibInfo(Generator.java:686) at com4j.tlbimp.Generator.getTypeName(Generator.java:663) at com4j.tlbimp.TypeBinding.bind(TypeBinding.java:173) at com4j.tlbimp.MethodBinder.declareReturnType(MethodBinder.java:542) at com4j.tlbimp.MethodBinder.declareWithDefaults(MethodBinder.java:399) at com4j.tlbimp.MethodBinder.declare(MethodBinder.java:118) at com4j.tlbimp.InvocableInterfaceGenerator.generateMethod(InvocableInte rfaceGenerator.java:39) at com4j.tlbimp.InterfaceGenerator.generate(InterfaceGenerator.java:94) at com4j.tlbimp.Generator$LibBinder.generate(Generator.java:491) at com4j.tlbimp.Generator.generate(Generator.java:112) at com4j.tlbimp.driver.Driver.run(Driver.java:107) at com4j.tlbimp.driver.Main.doMain(Main.java:132) at com4j.tlbimp.driver.Main.main(Main.java:56)
Solution
tlbimp-20110320. Jar requires args4j-2.0 1. Jar and com4j-20110320 jar
Additional information
The latest version of Tlbimp (tlbimp-2.1. Jar) requires args4j-2.0 8. Jar and com4j-2.1 jar. In this release, you do not need to change the file name
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码