| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Tyler" |
| Date: |
26 Nov 2003 07:05:15 AM |
| Object: |
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
.
|
|
| User: "Frank Schmitt" |
|
| Title: Re: Communication between a C++ and Java program? |
26 Nov 2003 07:56:40 AM |
|
|
(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
.
|
|
|
| User: "Eric Boutin" |
|
| Title: Re: Communication between a C++ and Java program? |
28 Nov 2003 07:20:51 PM |
|
|
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" <invalid@see-signature.info> a écrit dans le message de
news:4cn0aji67b.fsf@scxw21.4sc...
hobbit_jr@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
.
|
|
|
| User: "lilburne" |
|
| Title: Re: Communication between a C++ and Java program? |
28 Nov 2003 07:26:41 PM |
|
|
Eric Boutin wrote:
maybe system("java programname > ./tmpfile") then parse ./tmpfile ?
http://www-919.ibm.com/servers/eserver/iseries/developer/java/devkit/rzaham80.htm
.
|
|
|
|
|
|
| User: "Dirk Feytons" |
|
| Title: Re: Communication between a C++ and Java program? |
26 Nov 2003 07:10:44 AM |
|
|
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.
.
|
|
|
| User: "red floyd" |
|
| Title: Re: Communication between a C++ and Java program? |
26 Nov 2003 10:51:16 AM |
|
|
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.
.
|
|
|
|
|

|
Related Articles |
|
|