How to call a COM object within java?

Showing Answers 1 - 1 of 1 Answers

Supraja

  • Feb 17th, 2006
 

com4j


A Java library that allows Java applications to seemlessly interoperate with Microsoft Component Object Model.
First generate Java type definitions from a COM type library. Here we are doing for the type library for the Windows Scripting Host.

> java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx


Then we are able to call WSH objects/methods. public class Main {
  public static void main(String[] args) {
    IFileSystem3 fs = ClassFactory.createFileSystemObject();
    for( String file : args )
      System.out.println(fs.getFileVersion(file));
  }
}


See https://com4j.dev.java.net/

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions