How java communicate with c++ (experts please take a look)

I encounter problems in my new project.

My client uses websphere as their app server and put ejb on it. They are now trying to introduce an image server on another machine to deal with image processing function. The image server provides some visual c++ lib calls and functions for programmer to work for, but it doesn't support java. So my client now asking me to write some java package for the websphere which hidden all c++'s works and call the image server to work(the 2 servers is distributed).

I start investigation from JNI at first. however, I found that JNI needs customizes the C++ code and of course i won't have it. So I give up this. Then, I start thinking to put a layer on the C++, and then use JNI to deal with this c++ layer. These steps I think should be on image server. So the next step is use RMI or Corba to communicate the websphere and image server, right?

I dont know whether this can be work or not, but I feel its to complex. I then think whether I can directly access the c++ file on the image server if I just know the image server's dll or function. I even dont know whether the image server have COM or support corba...

Can expertists give me some suggestions or reference!?

Thx a lots!!

[1269 byte] By [denniswty] at [2007-9-26 14:18:06]
# 1

You can always use an "adapter" design pattern to do your stuff.

In practice, you can create a java class for each C++ class you have to deal with. The idea is that a java object holds a C++ object (you can for instance store its address in a byte[] field). each C++ method can become a java native method, where the generated C function makes the glue.

Sometimes, afterwards, you can simplify the models. (avoiding having too many unnecessary classes in Java, by breaking the one-to-ona above rule)

for C functions, the easiest is to map them in an unstanciable java class to static methods. (see java.lang.Math for such a design).

hope this helps....

cdore at 2007-7-2 15:53:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
You might want to take a look at the Java Advanced Imaging Interface, things like networked graphic manipulation etc are supported by it. It comes with both native and java pure "drivers" and may be a better solution for your needs.
andyba at 2007-7-2 15:53:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Thanks for your help!! I am deciding to write a wrapper file by c++ which inculdes all the dll functions I needed. And will use JNI to work with that wrapper file.
denniswty at 2007-7-2 15:53:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...