1

I tried creating an ActiveXComponent object by clsid Like below:

public static void main(String[] args) {
    System.setProperty(LibraryLoader.JACOB_DLL_PATH, "C:\\Users\\TelC\\Downloads\\jacob-1.19\\jacob-1.19-x64.dll");
    LibraryLoader.loadJacobLibrary();
    ActiveXComponent comp=new ActiveXComponent("clsid:5B769435-52C8-11D2-B347-444553540000");
    System.out.println("The Library been loaded, and an activeX component been created");
}

but I get following exception:

com.jacob.com.ComFailException: Can't find moniker

I would be happy if someone could explain me what I'm doing wrong.

I have not done anything out of my program , such as registering any dll(s) or something.

A.Shaheri
  • 450
  • 4
  • 13
  • Maybe this is helpful: https://stackoverflow.com/questions/16147193/cant-co-create-object-cant-find-moniker-jacob You should register the DLL I think. – Arnold Schrijver Jul 21 '18 at 08:08
  • @Freeman I don't know anything about installing JCO, I just added a jar file for jcob to my project. How should I install JCO? – A.Shaheri Jul 21 '18 at 08:13
  • @Freeman I mean jcob not jco, what is the difference between them and what is JCO good for? – A.Shaheri Jul 21 '18 at 08:22
  • JACOB is a JAVA-COM Bridge that allows you to call COM Automation components from Java. It uses JNI to make native calls to the COM libraries.
    SAP JCo is a communication library, based on RFC which is an SAP interface protocol that simplifies the programming of communication processes between systems.
    – Freeman Jul 21 '18 at 08:26
  • 1
    @Freeman SAP is not free – Mohse Taheri Jul 21 '18 at 13:28

1 Answers1

1

Instead of creating a new ActiveXComponent you should create it by the createNewInstance method:

    System.setProperty(LibraryLoader.JACOB_DLL_PATH, "C:\\Users\\TelC\\Downloads\\jacob-1.19\\jacob-1.19-x64.dll");
    LibraryLoader.loadJacobLibrary();
    ActiveXComponent comp=ActiveXComponent.createNewInstance("clsid:5B769435-52C8-11D2-B347-444553540000");
    System.out.println("The Library been loaded, and an activeX component been created");
Mohse Taheri
  • 741
  • 1
  • 6
  • 23