4

I am trying to generate wrapper for com4j using tlbimp-20110320.jar. I also tried a 2008 version with the same errors. I get the same errors even when I try running against the example in the 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 a required library I was able to get it to run a little. However I had to copy the arg4j contents into the tlbimp jar, and the com4j contents into the tlbimp jar as well. 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)

3 Answers3

1

tlbimp-20110320.jar is required args4j-2.0.1.jar and com4j-20110320.jar
Note: com4j-20110320.jar, it is necessary to change the name to com4j.jar

Additional Info

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

YujiSoftware
  • 1,281
  • 14
  • 15
0

Unjar tlbimp.jar and check out its manifest. It has a classpath where args4j and com4j must be in the same directory as tlbimp.jar and require specific names. The specifics of the name depend on the build and may or may not include version number. Name your com4j and arg4j as indicated and you're good to go.

Matt Hovey
  • 85
  • 5
0

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

IceMan
  • 1,398
  • 16
  • 35
  • Ok. I downloaded the args4j-2.0.19.jar file, stuck it in /lib and the same error. I then tried it in the same directory and still the same error. –  Mar 04 '12 at 05:52
  • Ok. I think I got it to work a little. I had to copy the args4j jar contents into the tlbimp jar. Then I got a different error which I could only resolve by doing the same with the com4j contents. It started to run for a bit before generating a NPE. –  Mar 04 '12 at 05:56
  • 1
    Was there any progress on this since then? – monksy Aug 05 '14 at 21:39