1

I have this chess engine Rybka.exe, that i have to execute in java Here is an example how you run Rybka: Once you clicked on it, console opens and waits for input. So then you enter "uci" and you press enter and you wait for it to load (approx. 1 sec) and then you have to enter a few more lines as options and stuff. The problem is that I don't know how to pass those commands from java to Rybka. The fact is that those commands need to be entered one at a time, because you have to wait for some to execute. This is how I tried to open it. Code:

Process p1 = Runtime.getRuntime().exec("Rybka.exe");

This works, because you can see that Rybka.exe is active in task manager, but I don't know how to pass commands to it.

user1189571
  • 195
  • 3
  • 5
  • 10
  • Possible duplicate of [Java Programming: call an exe from Java and passing parameters](https://stackoverflow.com/q/5604698/608639) – jww Aug 24 '18 at 12:44

2 Answers2

0

Have you tried passing parameters/commands as below?

Runtime.getRuntime().exec("Rybka.exe parameter1,parameter2");

Pramod
  • 26
  • 2
  • I did, but first it executes to fast, problably because it just executes Rybka.exe and secondly it doesn't give any output. I know that I created ouput ok, because if I execute something else that doens't need parameters works ok. – user1189571 Mar 31 '12 at 18:57
0

a) how to bind a windows console application with java application?

link provided by the courtesy of Google search query:

https://www.google.pl/search?q=java+binding+console+to+an+app&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

b) in short:

 InputStream is = p1.getInputStream();
 OutputStream os = p1.getOutputStream();

(supplied by the obvious http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Process.html)

Community
  • 1
  • 1
  • Note: rybka (as all UCI/WinBoard engines) does distinguish **parameters** (used for setting the engine's state at run time) from **commands** (passed to the running engine); see http://en.wikipedia.org/wiki/Universal_Chess_Interface and http://wbec-ridderkerk.nl/html/UCIProtocol.html (result of ~5 seconds of googling) –  Mar 31 '12 at 19:00
  • I can't believe I was so blind. Thanks for making me see it again and get it. I used input to print the output of console, but I never thought about doing it reverse. – user1189571 Mar 31 '12 at 19:06