title: Accessing a Windows COM Interface using Java, Error loading type library/DLL. : .\com4j.cpp
body: <p>I need to access a Windows COM interface using my Java application. The COM interface in inbuilt in the executable for the program I'm talking to. </p>
  
  <p>I tried com4j but keep getting this exception, I'm running it only from the command prompt for now-</p>
  
  <pre><code>cmd:&gt; java -jar tlbimp.jar -o exe -p abc.exe executableFile.exe
  
  Exception in thread "main" com4j.ExecutionException: com4j.ComException: 80029c4
  a LoadTypeLib failed : Error loading type library/DLL. : .\com4j.cpp:398
          at com4j.ComThread.execute(ComThread.java:203)
          at com4j.Task.execute(Task.java:25)
          at com4j.COM4J.loadTypeLibrary(COM4J.java:322)
          at com4j.tlbimp.driver.Lib.getLibid(Lib.java:90)
          at com4j.tlbimp.driver.Driver.addLib(Driver.java:38)
          at com4j.tlbimp.driver.Main.doMain(Main.java:123)
          at com4j.tlbimp.driver.Main.main(Main.java:56)
  Caused by: com4j.ComException: 80029c4a LoadTypeLib failed : Error loading type
  library/DLL. : .\com4j.cpp:398
          at com4j.Native.loadTypeLibrary(Native Method)
          at com4j.COM4J$2.call(COM4J.java:324)
          at com4j.COM4J$2.call(COM4J.java:322)
          at com4j.Task.invoke(Task.java:51)
          at com4j.ComThread.run0(ComThread.java:153)
          at com4j.ComThread.run(ComThread.java:134)
  </code></pre>
  
  <p>What (if any) are the workarounds? Is this the correct approach to begin with? Never worked with COM before, so I'm wondering if I'm on the right path here.</p>
  
  <p>Also if this command were to work, I believe I would get Java definitions for all the interfaces in there, which I can then access directly in my code? </p>
  
  <p>Do I have to run this command from my java code every time my program starts up and generate new objects or is this a one time thing?</p>
  
  <p>Thanks!</p>