Problems with the com4j shell

I am trying to create a wrapper for com4j using tlbimp-20110320.jar. I also tried version 2008 with the same errors. I get the same errors even when I try to work with an example in tut.

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 provided a link to the desired library, I was able to get it to work a little. However, I had to copy the contents of arg4j to the tlbimp jar and the contents of com4j to the tlbimp jar. Now i get

 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) 
+4
source share
3 answers

tlbimp-20110320.jar requires args4j-2.0.1.jar and com4j-20110320.jar
Note: com4j-20110320.jar, you must change the name to com4j.jar

Additional Information

. tbbimp latest version ( tlbimp-2.1.jar ), requires args4j-2.0.8.jar and com4j-2.1.jar .
In this version, changing the file name is not required.

+1
source

From the stack trace, it looks like you are not seeing dependent jars from the java class path. The program seems to be looking for the Koshuke args4j library - http://args4j.kohsuke.org/ .

0
source

Cancel tlbimp.jar and check its manifest. It has a class path where args4j and com4j must be in the same directory as tlbimp.jar and require specific names. The specifics of the name are assembly dependent and may or may not include a version number. Name your com4j and arg4j as indicated, and you're good to go.

0
source

Source: https://habr.com/ru/post/1399513/


All Articles