I want to run a program like a video game in java and have it output everything it does in java, is this possible? To clarify on everything, I want to see the output of the game in terms of what it is doing. I understand it may not come out completely comprehensible since it would be in a different program language. Anyone here remember using a gameshark/gamegenie to hack a game for codes? That is kind of what I want to do.
I tried runtime and processbuilder so far, but it out puts nothing.
Below is my code:
public class ProcessW {
public static void main(String[] args) throws IOException {
String command = "...my game...";
ProcessBuilder pb = new ProcessBuilder(command);
pb.redirectErrorStream(true);
Process proc = pb.start();
java.io.InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
int exit = -1;
while ((line = br.readLine()) != null) {
// Outputs your process execution
System.out.println(line);
try {
exit = proc.exitValue();
if (exit == 0) {
// WinProcess finished
}
} catch (IllegalThreadStateException t) {
// The process has not yet finished.
// Should we stop it?
//if (processMustStop())
// processMustStop can return true
// after time out, for example.
proc.destroy();
}
}
}
}