Solved

A Java and C++ program - communicate!

Posted on 2002-05-28
8
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

733 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