For no particular reason I decided to try to communicate with nethack through java. I learned that nethack normally communicates to the consoles standard out using WriteConsole() or something similar, so I tried running nethack with runtime.exec() and letting it communicate with the virtual machine, but clearly my expectations were unfounded since this did not work.
Here is what I tried first.
When that didn't work I tried this.Code :try { rt = Runtime.getRuntime(); p = rt.exec(program); } catch (Exception ex) { System.exit(1); }
I've tried a few variations, but I never got back any lines from nethack's output. Is what I want to do possible with only java? What would I need to do to get this to work if it does happen to be possible? Also this looks like a nice forum, and tell me if I'm doing anything wrong.Code :try { BufferedReader botIn = new BufferedReader(new InputStreamReader(p.getInputStream)); } catch (Exception ex) { System.exit(1); } while (line = botIn.readLine() != null) { System.out.println(line); }
