I have a program that is supposed to open a different program in c++, which will return 0, 1, 2, or 3. As a test, I made some sample code:
public class Tester {
public static void main(String[] args) {
String[] command = {"c:\\Java Prog\\helloWorld.exe"};
ProcessBuilder proc = new ProcessBuilder(command);
System.out.println(proc);
}
}
The C++ Program was simply:
#include <iostream>
using namespace std; // I know, I know, it's bad.
int main(void) {
return 2;
}
This printed out:
java.lang.ProcessBuilder@1db9742
I was expecting that. However, when I tried to cast the output to an int (or anything else), the compiler (Eclipse Mars) told me that it could not cast from ProcessBuilder to [insert any variable type of your choice here].
What am I doing wrong? Can I format the output to an int? If not, how should I? Thanks in advance