Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

COM object in Java

 
Suman Mummaneni
Ranch Hand
Posts: 92
Google App Engine Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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.

 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Suman Mummaneni
Ranch Hand
Posts: 92
Google App Engine Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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.

-Cheers
 
Pradeep Kadambar
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic