Is it possible to call a COM API from Java? [closed]
Asked Answered
S

5

9

Is it possible to call a COM API from Java (specifically the HP/Mercury Quality Center OTA API)? If so, what's the best way?

Is something like JACOB appropriate?

Code fragments would be helpful for the basics :-)

Sensational answered 26/9, 2008 at 6:26 Comment(1)
I've also found this to be useful: com4jSupercilious
M
10

jacob : yes, http://sourceforge.net/projects/jacob-project/ is an active project that will suite your purpose pretty well.

you can see multiple examples : http://jacob-project.wiki.sourceforge.net/Event+Callbacks

but if you want something that is more tested and are willing to pay money, then go for http://www.nevaobject.com/_docs/_java2com/java2com.htm.

Minna answered 26/9, 2008 at 6:41 Comment(0)
A
4

after a comparison of all the above, none was totally satisfactory.

the most complete solution is in https://github.com/java-native-access/jna

now.

It supports,

  • getting interface to a running COM object
  • starting a new COM object and returning its interface
  • calling COM methods and returning results
  • optional separate COM thread handling
  • ComEventCallbacks
  • RunninObjectTable queries
  • lowlevel COM use
  • util / high level java proxy abstraction

E.g.

MsWordApp comObj = this.factory.createObject(MsWordApp.class);

Documents documents = comObj.getDocuments();
_Document myDocument = documents.Add();

String path = new File(".").getAbsolutePath();
myDocument.SaveAs(path + "\\abcdefg", WdSaveFormat.wdFormatPDF);
comObj.Quit();
Andress answered 27/4, 2017 at 12:58 Comment(0)
S
2

maybe you should have a look at http://qctools4j.sourceforge.net/ it's a java library used by qclylyn (http://sourceforge.net/apps/mediawiki/qcmylyn/index.php?title=Main_Page) to retrieve defects from QC.

unfortunately the COM bridge doesn't work for linux as it loads jacob dlls

Schaffer answered 11/10, 2010 at 16:30 Comment(0)
O
1

j-Interop is a Java-COM bridge: j-Interop. It's written in pure Java and licensed under the LGPL v3. It uses the DCOM wire protocol to call COM objects as opposed to the JNI approach used by JACOB.

Owen answered 10/3, 2010 at 9:37 Comment(0)
P
1

You can use J-Integra COM2JAVA tool. The com2java tool generates Java "proxy" classes and interfaces that correspond to the coclasses and interfaces contained in a COM type library. It effectively generates a Java API which you can use to access a COM component from Java.

Peebles answered 17/12, 2010 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.