title: Failed to execute COM class: com4j.ComException: 80040154 CoCreateInstance failed : Class not registered : .\com4j.cpp:153
body: <p>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: <a href="https://stackoverflow.com/questions/50392321/call-a-dll-function-using-command-line">Call a .dll function using command line</a></p>
  
  <p>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":</p>
  
  <pre><code>@DISPID(1610809376) //= 0x60030020. The runtime will prefer the VTID if present
    @VTID(8)
    int getUnitInfo(
      java.lang.String strRequest,
      Holder&lt;java.lang.String&gt; strUnitInfo,
      @Optional @DefaultValue("") java.lang.String strStationName,
      @Optional @DefaultValue("") java.lang.String strUserID);
  </code></pre>
  
  <p>The instance:</p>
  
  <pre><code>Holder&lt;String&gt; holder = new Holder&lt;String&gt;("test");
          _Tester instance =  ClassFactory.createTester();
          instance.getUnitInfo("", holder, "", "");  
  </code></pre>
  
  <p>But it throws this exception:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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.</p>
  
  <p>If I execute "java -version" o the command line:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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.</p>
  
  <p>Can anybody help?</p>
  
  <p><strong>EDIT</strong>
  The instance is create using this UUID:</p>
  
  <pre><code> public static DLL._Tester createTester() {
      return COM4J.createInstance( DLL._Tester.class, "{4B7CF2DB-F936-4BA3-9DC6-5E99E5220270}" );
    }
  </code></pre>
  
  <p>And I found this in the Windows registry:
  <a href="https://i.stack.imgur.com/mOxnR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mOxnR.png" alt="enter image description here"></a></p>