• Post Reply Bookmark Topic Watch Topic
  • New Topic

COM Object call from Java

 
fahad siddiqui
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a SSDocumentConverter.dll which is a COM object which has method to convert ppt to html.
I want to invoke this from java.

How? please explain with some code.

I tried bridge2java from ibm. but i think it requires some bridge2java.dll file.

Lets see it step by step.

I need to load the SSDocumentConverter.dll as a library in java..
what next??
I am quiet confused.

Please explain like a layman.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Loading that library in Java code won't do much good, because Java has no way of using it directly. Have a look at the Jacob project, which provides a JNI bridge from Java to COM objects.
 
fahad siddiqui
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not so clear on how to use jacob bridge to make the callls.

Could you please explain the same in a sample code.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jacob home page has plenty of links to FAQs, a Yahoo support group, examples aand further helpful resources. Have you gotten the examples to work?
 
fahad siddiqui
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to replicate the faqs and use a SSDocumentConverter.dll for the conversion.
I followed the steps in faqs and finally, made a class similar to math.java provided in the examples.

When i run it, it gives the following error.

Exception in thread "main" com.jacob.com.ComFailException: Can't get object clsi
d from progid
at com.jacob.com.Dispatch.createInstance(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java)
at math.main(math.java:12)

I am pasting the class also.
Please help.

import com.jacob.com.*;
class math
{
public static void main(String[] args)
{
System.runFinalizersOnExit(true);
Dispatch test = new Dispatch("SSDocumentConverter.Math");
testEvents te = new testEvents();
DispatchEvents de = new DispatchEvents(test, te);
System.out.println(Dispatch.call(test, "PPT2HTML", new Variant("C:\\Dll\\powerpnt.ppt"), new Variant("C:\\power.html")));
Variant v = Dispatch.call(test, "PPT2HTML", new Variant("C:\\Dll\\powerpnt.ppt"), new Variant("C:\\power.html"));
}
}

class testEvents {
public void DoneAdd(Variant[] args)
{
System.out.println("DoneAdd called in java");
}
public void DoneMult(Variant[] args)
{
System.out.println("DoneMult called in java");
}
}
 
Jean-Francois Briere
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's much simpler than you might think.
From the help of SSDocument Converter you read:



Then to "traduct" those VB lines as JACOB lines it's almost straightforward:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!