views:

1085

answers:

1

I maintain a legacy Java application that uses Jacob, or Java-COM Bridge, to make calls via the COM interfaces of MS VBA and MS Word. I have been looking at com4j from Sun, and it looks promising.

The reason it looks good to me is that it uses vtable binding to methods, instead of IDispatch. Assuming all the COM objects we manipulate present vtable interfaces, it seems cleaner to use them instead of IDispatch. Back in the days when COM and CORBA where the hot binary interface technologies, I seem to remember that early binding via the vtable gave better performance than late binding via IDispatch.

Has anyone migrated from Jacob to com4j? If so, what were the pitfalls and lessons learned?

+5  A: 

I've used both Jacob and Com4j in while integration against a simple COM object. I ended up going with Com4j mainly because Jacob leaked too much memory. Compared to Jacob, I think that Com4j was more straight forward once it is set up. If I remember correctly, Jacob required much more setting up and typing before doing the actual COM call. While in Com4j you'll just use the provided factory.

Com4j has been working OK for us, but we've hit a few bumps on the way. First, the generated interfaces wasn't correctly generated and we needed to manually tweak them. The main problems I remember was that we couldn't get the @ReturnValue annotation to work properly. Also, we needed to manually correct the @VTID enumeration.

One other major thing we faced was that we couldn't use the Holder (out params) class for shorts. We ended up making a Delphi wrapper converting from Integer to Short instead of doing any changes to Com4j.

Finally, I remember that I was a bit worried about the project status while I integrated. There seems to be no regular updates (two years now since the last maintenance release).

Samuel Sjöberg
Thanks. I didn't want to get into Jacob memory-leakage without providing details, but we've seen it, too. I think I'll do a demonstration project with com4j, and one with Jacob, and experience the differences first hand.
Stephen Harmon

related questions