I'm trying for some days to execute a ".dll" file from an JAVA application. If you are interested you can read my first question: Call a .dll function using command line
I used "com4j" to create the COM classes for my DLL. The generated classes looks good and I tried to execute the code, more exactly a method called "getUnitInfo" located in a class called "_Tester":
@DISPID(1610809376) //= 0x60030020. The runtime will prefer the VTID if present
@VTID(8)
int getUnitInfo(
java.lang.String strRequest,
Holder<java.lang.String> strUnitInfo,
@Optional @DefaultValue("") java.lang.String strStationName,
@Optional @DefaultValue("") java.lang.String strUserID);
The instance:
Holder<String> holder = new Holder<String>("test");
_Tester instance = ClassFactory.createTester();
instance.getUnitInfo("", holder, "", "");
But it throws this exception:
Exception in thread "main" com4j.ExecutionException: com4j.ComException: 80040154 CoCreateInstance failed : Class not registered : .\com4j.cpp:153
at com4j.ComThread.execute(ComThread.java:203)
at com4j.Task.execute(Task.java:25)
at com4j.COM4J.createInstance(COM4J.java:97)
at com4j.COM4J.createInstance(COM4J.java:72)
at DLL.ClassFactory.createTester(ClassFactory.java:21)
at proiect.DllTest.run(DllTest.java:17)
at proiect.DllTest.main(DllTest.java:11)
I have read a lot of posts regarding this problem on the internet but nothing helped. Using "PE deconstruct" tool to find out that the .dll file that I need to execute is 32 bit based. I have a 64 bit Windows OS but I installed a 32 bit JAVA and Eclipse.
If I execute "java -version" o the command line:
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode)
The com4j documentation is lacking information, I think the new generated JAva code still need to communicate with the old DLL but I don't know how it has to be referenced.
Can anybody help?
EDIT The instance is create using this UUID:
public static DLL._Tester createTester() {
return COM4J.createInstance( DLL._Tester.class, "{4B7CF2DB-F936-4BA3-9DC6-5E99E5220270}" );
}
And I found this in the Windows registry: