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