Solved

A Java and C++ program - communicate!

Posted on 2002-05-28
8
264 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 100 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will show, step by step, how to integrate R code into a R Sweave document
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

777 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