Solved

A Java and C++ program - communicate!

Posted on 2002-05-28
8
284 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

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!

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

690 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