The chess engine I'm working on is written in Java and is only an engine. For now I'm using
XBoard
as the GUI for the engine. (WinBoard to be precise, since I'm on a
Windows machine.)
XBoard expects a link to an exe for its engines and my
Java engine is actually a jar file. At first I looked at an exe wrapper
for jar files (Launch4j), but this was not successful. I use
this line to the engine in XBoard now:
"Chess JvO" -fcp "java -cp D:\ChessJvO\ChessJvO.jar ChessJvO"
The only downside to this is that the engine is now named "java" instead of "ChessJvO" in XBoard, but it works fine.
Communication with XBoard goes through standard in and out, which are System.in and System.out in java. It seems they are unbuffered by default in Java, so setting up the communication is quite easy. Output is simply sent to System.out and the input can be set up as follows:
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
try {
for (;;) {
String command = input.readLine();
if (command == null) return;
handleCommand(command);
}
} catch (IOException e) {
e.printStackTrace();
}
More information on the communication protocol with XBoard can be found on the page about the Chess Engine Communication Protocol.