0

I'm developing a project in visual c++ and at some point in code I need to execute some java jar program with some arguments and store it's output into a string So the code I execute in CMD and it works is:

java -jar weka.jar something.arff

And I get some text returned to the command prompt

I want to do the same thing with c++ and store the output into a string variable

I tried using system function, but as far as I know it's impossible to store output using that one I also tried using _popen, ( it did work with commands like dir etc...) but it didn't return any output when using the command provided above

Help would be appreciated

Raydel Miranda
  • 12,567
  • 2
  • 30
  • 56
Tadej Magajna
  • 2,198
  • 1
  • 21
  • 39
  • Might be helpful: http://stackoverflow.com/questions/43116/how-can-i-run-an-external-program-from-c-and-parse-its-output – Jeroen May 21 '14 at 19:14
  • thank you. Like said, I've already used _popen with this jar, but it didn't return any text – Tadej Magajna May 21 '14 at 21:27
  • How about you redirect the standard output to a file 'java -jar weka.jar something.arff > out' and the read from that file. – Andro May 21 '14 at 22:32
  • hmm I tried it with system() and now I've got another problem. It says: java is not recognized as an internal or external command – Tadej Magajna May 22 '14 at 00:31
  • @tadoman Can you run Java through a normal console? – Jeroen May 22 '14 at 15:39

0 Answers0