1

In a C++ application I need to launch a Java app and pass arguments to its standard input, when the java app is finished then receive the result in the C++ app. Is there a fast-easy way to do this without using files, sockets, etc?

PD: the java app is on the same directory that the c++ app.

Some examples? please, Sorry by my english

Orkun Kocyigit
  • 1,137
  • 10
  • 21
  • What do you mean by "pass arguments to its standard input"? Do you mean on the command line when you start the application, or do you mean the application reads from stdin after it starts? Also, what platform are you on? – Klitos Kyriacou Nov 30 '15 at 14:32
  • he mean launch a java app, from a c++ app pass arguments to the java app, which is gonna read that arguments and then do some process, after that it will emit the response to the same c++ app (that is waiting) – Jordy Baylac Nov 30 '15 at 19:37
  • Look at he answers to http://stackoverflow.com/questions/6171552/popen-simultaneous-read-and-write – Jerry Jeremiah Nov 30 '15 at 21:43

1 Answers1

5

The simplest way: you can just call external command with system() call and redirect result to some file. Then you can read the content of that file. This approach is not flexible, but very simple

system("java -jar YourJar.jar args ... > somefile");
nogard
  • 9,432
  • 6
  • 33
  • 53