0

I am facing exception Exception in thread "main" com.jacob.com.ComFailException: Can't co-create object while running the code below.

I checked online for help. Some sites say that I need to register my dll. I tried registering using regsvr32.exe. But I am unable to register successfully. Getting below popup.

The module "jacob-1.18-M2-x64.dll" was loaded but the entry-point DllRegisterServer was not found.Make sure that "jacob-1.18-M2-x64.dll" is a valid DLL or OCX file and then try again.

halfer
  • 19,824
  • 17
  • 99
  • 186
Shonali
  • 11
  • 1
  • 1
  • 1
  • String path = System.getProperty("java.library.path"); System.out.println(path); System.loadLibrary("jacob-1.18-M2-x64"); // Connect to iMacros Scripting Interface System.out.println("Started."); ActiveXComponent iim = new ActiveXComponent("imacros"); – Shonali May 30 '14 at 09:24
  • Can you please post a relevant snippet of the code you're running? – Craig Otis May 30 '14 at 09:47

3 Answers3

2

1.) You don't need to register the jacob-dll, it just has to be somewhere on your java.library.path. It is the dll that contains the COM-object that has to be registered.

2.) If the COM-dll is registered you have to take care to use the correct JVM with the library. 32-bit-dlls will work only with a 32-bit-JVM, 64-bit-dlls only with a 64-bit-jvm. Using the wrong JVM will result in the Can't co-create object error.

piet.t
  • 11,718
  • 21
  • 43
  • 52
  • Hi Piet! I am using 64 bit because I am using windows 7. I am using the below code and this code does not give an error. Please see the code below. String path = System.getProperty("java.library.path"); System.out.println(path); System.loadLibrary("jacob-1.18-M2-x64"); The problematic code is ActiveXComponent iim = new ActiveXComponent("imacros"); Kindly help!! – Shonali Jun 02 '14 at 02:42
  • What is your browser-version? 32 or 64 bit? Most windows7-installations run 32bit-InternetExplorer by default, so I guess any iMacros-plugin you install there will be 32 bit as well and thus require 32-bit java and jacob. – piet.t Jun 02 '14 at 07:19
1

I had the same problem and this is how I fixed it:

  1. Find your COM object using OLE/COM object Viewer
  2. Make sure to register your dll with regsvr32.exe (from C:\Windows\System32)
  3. You need to make a surrogate in order to access a 32-bit dll from a 64 bit app. See this here : http://www.gfi.com/blog/32bit-object-64bit-environment/
Adrian Muntean
  • 322
  • 2
  • 15
0

I encounted same problem and solved like following this. 1.Set lib path of jacob.jar 2.Copy jacob-x86.dll(or 64bit case jacob-x64.dll) to System32 directory.

import com.jacob.activeX.ActiveXComponent;

ActiveXComponent activeXComponent = new ActiveXComponent("ACTIVEX.ActiveXCtrl.1");