Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to choose a Java-COM bridge? [closed]

Tags:

java

com

I have to create an application which automates Outlook and Word and I want to use Java for that task. (The only allowed alternative would be VB6, so...)

After a quick Google survey I found several libraries, but I'm not sure which one to use:

  • J-Interop
  • SWT
  • JACOB
  • COM4J
  • jacoZoom
  • ...

I have no idea how to compare these libraries and make an informed decision. It seems that COM4J is a little bit outdated, JACOB leaks memory (allegedly) and jacoZoom is commercial. Each and every one seems to require a lot of boilerplate code to perform a simple method call. (Which might be unavoidable given the design of COM)

Besides that I have no idea how to choose between one of them. Which one is the best?

like image 247
Daniel Rikowski Avatar asked Aug 23 '10 12:08

Daniel Rikowski


5 Answers

We use Jacob in production environment and it works out pretty well. Nevertheless the projects seems to be not very active.

Speaking of which: Activity seems to be an advantage for J-Interop. We tried the project as well and it seems to work out pretty good with even better logging messages. I think we might choose J-Interop for new projects.

COM4J seems to be outdated, you're right.

like image 155
Christopher Avatar answered Nov 10 '22 02:11

Christopher


As a developer seasoned in Java/Linux but ignorant in Windows, here was my experience (August 2015)...

Executive summary:

  1. Go with com4j... with the caveat that:
  2. You may need to build the latest (unreleased) code to get some important recent fixes.

Longer story:

At first, the propensity for code involving JNI to crash inexplicably made me look for a non-JNI solution. J-Interop seemed to fit the bill.

However, as I tried to get j-interop to work, all the Windows DCOM permissions and registry crap made it a total PITA. It's different for different versions of Windows, required changes must be made as Administrator, etc. I don't understand any of this Windows crap and it makes me want to puke anyway.

I then tried com4j and it worked like a champ. This project is very nicely designed. It auto-generates Java interfaces from the DLL's you are using. COM calling convention details are declared using Java annotations on the interface methods, allowing you to tweak these if necessary (no tweaks were necessary in my case).

There are several developers on github who have forked the project and contributed back fixes, which is a healthy sign.

The only caveat is that you may require some of the recent fixes which, as of August 2015, are merged into the project but not contained in the latest release (which is from March 2014).

So you may need to do a custom build yourself, which includes building DLL's in Visual Studio, etc. Even as a Windows hater/ignorant, I was able to do this.

like image 26
Archie Avatar answered Nov 10 '22 00:11

Archie


COM4J still seems to be active - it has been moved to Github and has a new homepage: http://com4j.kohsuke.org/tutorial.html

like image 35
TmTron Avatar answered Nov 10 '22 02:11

TmTron


J-Integra by Intrinsyc Software http://j-integra.intrinsyc.com/ is your best option. It hides the complexity of having to know an unfamiliar programming language. It isn't dependent on JNI so you don't need to know JNI. J-Integra is also actively maintained and supported and Intrinsyc offers a pure 64-bit version for those people wanting to run in a pure 64-bit environment.

Intrinsyc offers free trials so you can test it out and see if it works before committing to any purchasing.

Companies like HP, IBM, SAP, and Oracle use it so you know its going to be fast, stable and well supported.

like image 3
user2045190 Avatar answered Nov 10 '22 01:11

user2045190


Appears bridj can do some COM interop as well: https://code.google.com/p/bridj/wiki/COM#Example

like image 1
rogerdpack Avatar answered Nov 10 '22 00:11

rogerdpack