A Java and C++ program - communicate!

hi!

The situation is something like this:

I have two processes running on my system. One of them is written in Java and one in C++. I need these two to be able to communicate. The code I write should be as platform independent as possible as finally I will need versions of these processes for both Unix and Windows.

Basically, the C++ program has to get the "state" of one of my objects from the Java program. So, in some sense I should be able to get the return value of "obj.getState()" (which returns a string) in the C++ program.

Any pointers will be greatly appreciated!

Thanks a tonne,

-- Asim
asim_shankarAsked:
Who is Participating?
 
CJ_SConnect With a Mentor Commented:
A fast search on the net got me to this: http://nacphy.physics.orst.edu/brian/socket.html

CJ
0
 
asim_shankarAuthor Commented:
Hi!

Thanks for the input, and I'm looking through that. Just a thought though: is there any cross-language RPC mechanism?

Thanks once again,

-- Asim
0
 
asim_shankarAuthor Commented:
Unfortunately, the code on the link you gave is not available.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
CJ_SCommented:
Well, if you are using microsoft's j++ then you can. Microsoft has given you a windows way of communicting with other applications (ActiveX). But you already stated that that is not an option.

Here's a working page:
http://www.javaworld.com/javaworld/javatips/jw-javatip17.html?

CJ
0
 
CJ_SCommented:
Any update?
0
 
asim_shankarAuthor Commented:
CJ,

Thanks for all the pointers, but the last link you sent was about calling C code from Jav and vice-versa. What I need was some IPC mechanism.

I guess the best option is to use sockets. Unfortunately, that would require some rewrite for different platforms at the C++ end.

Maybe someone should develop a cross-language/cross-platform RPC mechanism?!
0
 
asim_shankarAuthor Commented:
Basically, the first link you have had the useful idea, just not the code :-). If I find a better link by later today then I'll add that, otherwise will accept your posting as the answer.
0
 
CJ_SCommented:
:-)

There's one option that keeps popping up in my head. If you can let both programs use sockets and listen to those sockets you can send XML to the other program on the right port.

But I don't have any sourcecode of that :-/ (not for java at least).

CJ
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.