Java aus C++ aufrufen
-
Hallo, ich bräuchte mal eure Hilfe:
Ich möchte aus meinem C++ Quellcode heraus ein java Programm aufrufen,
also irgendwie von meinem C++ Programm "java prog" + return in die Kommandozeile schreiben lassen.
Hat wer Rat?
Danke im Vorraus
-
-
hey super,
nur noch mal zum Verständnis:
d.h.
const String command = "java helloworld"; const Sting type = w; FILE *popen(*command, *type);
erzeugt im Endeffekt eine shell und führt den Befehl "java helloworld" aus?
Und mit
pclose(File *stream);
schließt diese wieder?!
Gruß und Danke im Vorraus
-
Eher:
FILE *fp = popen ("java helloworld", "r"); pclose (fp);
(bzw. "w" statt "r", wenn du irgendwas in die Standard-Eingabe des Programms schreiben willst).
Zu
pclose ()
steht alles auf der Seite, die ich verlinkt habe.
-
ok, das klappt so weit.
Nun möchte ich gerne mehrere Befehle ausführen. Welche Funktionen kann ich da benutzen? Ich kann ja nich für jeden Befehl ne neue Shell aufmachen ... z.B. für
cd ..
java helloworldmacht das keinen Sinn
Gruß und Danke im Vorraus
-
chdir ("..");
?!