File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes COM object in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "COM object in Java" Watch "COM object in Java" New topic

COM object in Java

Suman Mummaneni
Ranch Hand

Joined: Dec 14, 2004
Posts: 89


If I want to use a COM object in Java how do I do it. I need to access a COM dll in my Java class. I can do this using JNI wrapper classe or should I clreate a new DLL for this again.

Suman Mummaneni
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
This article introduces a library for that purpose which is available from IBM Alphaworks. I've never used it, so can't comment on it.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Google on "Java COM bridge" and find many products ranging from free and unsupported to very expensive. Consider a JNI solution where you call from Java to a custom C++ module you write just to talk to a particular COM object. Let us know what you wind up with!

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Suman Mummaneni
Ranch Hand

Joined: Dec 14, 2004
Posts: 89


Well for me JNI came to the rescue. I had to write a small C++ class to access some function from another DLL file. So that closed the matter.

Pradeep Kadambar
Ranch Hand

Joined: Oct 18, 2004
Posts: 148
Accessing COM objects has been made simple with Java COM bridges.

For example : JACOB

It is quite efficient. It internally uses JNI for this purpose.

Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
If you are using COM from JNI, beware of the threading model of the COM object. In-proc COM objects should be fine and simply creating and releasing COM object within your JNI call is fine.

However, if you are creating an out-of-proc COM object in one thread and using it in another, you might run into problems.
I agree. Here's the link:
subject: COM object in Java
jQuery in Action, 3rd edition