473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Communication between a C++ and Java program?

Hi ppl,

I know it's forbidden to mention Java in this newsgroup but I've been
presented with a problem which requires that my C++ program
communicate with another java program.

What is the best,simplest and quickest way to go about this?

I was thinking, I could have my C++ program write data to a file and
then my Java program pick it up from there but this is a little too
slow for my needs. What about writing to an environment variable in
the OS? I know java can do that but can C++ do that? Any ideas
anyone?

Many thanks.

Tyler
Jul 22 '05 #1
5 3067
Tyler wrote:
I know it's forbidden to mention Java in this newsgroup but I've been
presented with a problem which requires that my C++ program
communicate with another java program.

What is the best,simplest and quickest way to go about this?


How about using sockets?

--
Dirk

(PGP keyID: 0x448BC5DD - http://www.gnupg.org - http://www.pgp.com)

..oO° "I've seen things you people wouldn't believe. Attack ships on fire
off the shoulder of Orion. I watched C-beams glitter in the dark near
the Tannhauser gate. All those moments will be lost in time, like tears
in rain. Time to die." -- Blade Runner °Oo.

Jul 22 '05 #2
ho*******@yahoo.com (Tyler) writes:
Hi ppl,

I know it's forbidden to mention Java in this newsgroup but I've been
presented with a problem which requires that my C++ program
communicate with another java program.

What is the best,simplest and quickest way to go about this?

I was thinking, I could have my C++ program write data to a file and
then my Java program pick it up from there but this is a little too
slow for my needs. What about writing to an environment variable in
the OS? I know java can do that but can C++ do that? Any ideas
anyone?


Some ideas (none tested):

- use a shared memory segment (man shmget on Unix)
- if your java program just needs the data from the C++ program, use
a pipe
- use Javas JNI facility
- use a framework like CORBA

Of course, all of these are OT in comp.lang.c++ :-)

HTH & kind regards
frank

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com
Jul 22 '05 #3
Dirk Feytons wrote:
Tyler wrote:
I know it's forbidden to mention Java in this newsgroup but I've been
presented with a problem which requires that my C++ program
communicate with another java program.

What is the best,simplest and quickest way to go about this?

How about using sockets?


That's what we did instead of using JNI.

Jul 22 '05 #4
maybe system("java programname > ./tmpfile") then parse ./tmpfile ?

this is almost std c++.. the only issue that is not standard is stdout
redirection in the system function, but this program will compile on any
implentation.. and almost all OS support > to redirect stdout.. not big
deal.. or you could also create a file with all the data the java program
need, pass it to the program as a command line argument, then redirect the
output and parse it.. but be shure both files are in ansci mode.. and no,
passing a pointer to the other program is not a good idea.

hope it help

-Eric

"Frank Schmitt" <in*****@see-signature.info> a écrit dans le message de
news:4c************@scxw21.4sc...
ho*******@yahoo.com (Tyler) writes:
Hi ppl,

I know it's forbidden to mention Java in this newsgroup but I've been
presented with a problem which requires that my C++ program
communicate with another java program.

What is the best,simplest and quickest way to go about this?

I was thinking, I could have my C++ program write data to a file and
then my Java program pick it up from there but this is a little too
slow for my needs. What about writing to an environment variable in
the OS? I know java can do that but can C++ do that? Any ideas
anyone?


Some ideas (none tested):

- use a shared memory segment (man shmget on Unix)
- if your java program just needs the data from the C++ program, use
a pipe
- use Javas JNI facility
- use a framework like CORBA

Of course, all of these are OT in comp.lang.c++ :-)

HTH & kind regards
frank

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com

Jul 22 '05 #5
Eric Boutin wrote:
maybe system("java programname > ./tmpfile") then parse ./tmpfile ?


http://www-919.ibm.com/servers/eserv...t/rzaham80.htm

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ^CeFoS^ | last post by:
Hi to everybody, due to I want to use the serial port of a server machine through an applet allocated in html document. > Then one application will run in the server machine and using > the serial...
3
by: Jacques Daussy | last post by:
Hello How can I transfert information between a JAVA application and a python script application. I can't use jython because, I must use python interpreter.I think to socket or semaphore, but can...
1
by: Praveen | last post by:
Hi, I have installed WebSphere Portal on AIX and connected to DB2 on a remote machine, Getting the followin errors when trying to get the values from database thru applications installed on...
0
by: Mihir Vaidya | last post by:
I want a C# and a JAVA process to communicate with each other using IPC or Pipes. I tried the following. 1. Invoke the JAVA Program. 2. Spawn a C# process using the Runtime.exec() command. 3....
0
by: news.onet.pl | last post by:
I hava a problem with communication between Java/Corba server based on JDK ORB with Java/Corba client (applet) based on the same ORB. I`m using IOR to localize server. client`s ORB i initialize...
7
by: bylum | last post by:
Servlet SQLException Communication link failure java howto i can't connect jsp and database(mysql). This is the exception: exception org.apache.jasper.JasperException:...
6
by: Kasper Lindberg | last post by:
Hi NG, How to do two-way-interprocess communication using java? Imagine a client/server setup where the client can request a number of functions to be performed by the server. Since the...
5
by: AeonOfTime | last post by:
Let's assume a web application (in this case a browser-based game) with a custom HTTP server built on PHP, and a client also built on PHP. The client uses the server to access and change data. Even...
0
by: rcreddych | last post by:
I am getting the following error while deploying a simple Java Stored Procedure. I am using db2 8 and using the IBM Data Studio. I am new to DB2. Your help will be apreciated. CHETR.PROCEDURE1 -...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.