?
Solved

A Java and C++ program - communicate!

Posted on 2002-05-28
8
Medium Priority
?
296 Views
Last Modified: 2010-04-17
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
0
Comment
Question by:asim_shankar
  • 4
  • 4
8 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 300 total points
ID: 7040097
A fast search on the net got me to this: http://nacphy.physics.orst.edu/brian/socket.html

CJ
0
 

Author Comment

by:asim_shankar
ID: 7040108
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
 

Author Comment

by:asim_shankar
ID: 7040112
Unfortunately, the code on the link you gave is not available.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 22

Expert Comment

by:CJ_S
ID: 7040132
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 7044292
Any update?
0
 

Author Comment

by:asim_shankar
ID: 7044769
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
 

Author Comment

by:asim_shankar
ID: 7044773
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 7046384
:-)

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question