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/
See also this HowTo for an alternative package to access a COM package from Java.
Written and compiled by Réal Gagnon ©1998-2005
[ home ]