I've been trying to learn some Java programming. I thought a good exercise would be to write a simple engine. I started with a really simple one just to see if I could 'talk' to winboard. All the program does is get two winboard commands and send a message back. I built my .jar file and copied it to my winboard directory. I then opened a cmd prompt, navigated to the winboard folder and ran my program with:
I got Startup failure on 'java -jar moron.jar': The System cannot find the file specified. I'm not sure who can't find what. I verified that there is a java.exe in my path. I'm probably missing something obvious but damned if I can see what it is.
The winboard debug file and a listing of my program are below. Any help would be greatly appreciated.
Compiling a Java Program with GCJ
Using GCC to run a Java program is familiar to anyone who has used it for C or C++ programs.
To compile the Java program MyJavaProg.java, type:
gcj -c -g -O MyJavaProg.java
To link it, use the command:
gcj --main=MyJavaProg -o MyJavaProg MyJavaProg.o
This is just like compiling a C++ program mycxxprog.cc:
g++ -c -g -O mycxxprog.cc
and then linking to create an executable mycxxprog:
g++ -o mycxxprog mycxxprog.o
Ah ha. At least I don't feel like quite such a dunce. I made an exe with Launch4j and winboard started it okay but they didn't talk. A dos window opened and stayed open. I typed in two entrys, moron replied and exited. Winboard saw that it was gone and announced that first chess program quit unexpectedly.
Launch4j has a ton of settings, I'll have to study those. I think you've got me headed in the right direction. Thanks much.
Ah ha. At least I don't feel like quite such a dunce. I made an exe with Launch4j and winboard started it okay but they didn't talk. A dos window opened and stayed open. I typed in two entrys, moron replied and exited. Winboard saw that it was gone and announced that first chess program quit unexpectedly.
Launch4j has a ton of settings, I'll have to study those. I think you've got me headed in the right direction. Thanks much.
Getting closer. I received xboard and new. Don't know what happened to protover 2. Winboard doesn't seem to have received my features. I think I need to add more functionality to figure out what's happening.
Dan Honeycutt wrote:Getting closer. I received xboard and new. Don't know what happened to protover 2. Winboard doesn't seem to have received my features. I think I need to add more functionality to figure out what's happening.
Best
Dan H.
It is possible that you also need to take care about using non-buffered input, since otherwise some WinBoard command lines might be sitting in some buffer for a while. I don't know how to do it in Java. In C you would use something like setbuf(stdin, 0) or setvbuf(stdin, ...).
Sven Schüle wrote:It is possible that you also need to take care about using non-buffered input, since otherwise some WinBoard command lines might be sitting in some buffer for a while. I don't know how to do it in Java. In C you would use something like setbuf(stdin, 0) or setvbuf(stdin, ...).
Sven
I think you hit on the problem, Sven. With some more tinkering I determined that I was sending to Winboard fine but I was only receiving about half of the commands Winboard sent me. I changed from the scanner to a buffered reader, in Java:
JuLieN wrote:Can't Winboard accept .bat files as engines? If yes, just run it with java "your_jar.jar"
No luck. First I tried a batch file to start winboard and feed it java my_jar and got the same error as per my original post. Next I put java my_jar in a batch file and fed that to Winboard. This time I got the error: first chess program exited unexpectedly.
Your batch file suggestion does have merit, though. I can run it as a console application by double clicking the batch file from Explorer (without having to open a cmd window). If I double click the jar file I get nothing since the file association is javaw and not java.
JuLieN wrote:Can't Winboard accept .bat files as engines? If yes, just run it with java "your_jar.jar"
No luck. First I tried a batch file to start winboard and feed it java my_jar and got the same error as per my original post. Next I put java my_jar in a batch file and fed that to Winboard. This time I got the error: first chess program exited unexpectedly.
Your batch file suggestion does have merit, though. I can run it as a console application by double clicking the batch file from Explorer (without having to open a cmd window). If I double click the jar file I get nothing since the file association is javaw and not java.