Before attempting any of the example programs or writing any of your own on a Windows machine, there is one thing to consider. Since Sun still supports versions of Windows prior to Win2000, the actual java.exe executable has a very small stack space limit. Since OEChem is written in C++ for performance, many algorithms internal to OEChem require a larger stack space than the 256K default as shipped from Sun.
See the following reference for more info:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4689767
There are two different approaches to dealing with this limitation, as outlined in the above bug status page.
Stack size under Windows is a link-time setting, so the executable (java.exe) as created by Sun has this 256K limit built in. Window however, has a simple utility to modify the stack space of an executable.
In a command window (or Cygwin shell), use the EDITBIN command to permanently modify the executable.
EDITBIN /STACK:16000000 C:\Path\To\java.exe
There are a couple of things to note about this procedure. First, there may be more than one "java.exe" installed on your machine. Make sure to apply this to each one, or at least be sure to apply to the one you'll be running Java-OEChem apps with. Second, if you upgrade/update the Java version, most likely this will have to be performed again.
If you are unable to modify your java.exe directly, you can still provide Java OEChem with an appropriate stack size by spawning a second thread with an expanded stack.
The java exectuable has a command line flag (-Xss) that can be used to spawn threads with an increased stack. To run a program with a 8MB stack, use:
java.exe -Xss=8M MyClass
Note however, that this does not apply to the original thread, but to new ones
so all the examples in this manual have to be modified as shown below. Most
examples simply declare a class with a static main the creates an
instance of the class and runs some method. We might write "hello, world"
like:
public class HelloWorld {
public void sayHi() {
System.out.println("Hello, world");
}
public static void main(String [] argv) {
HelloWorld app = new HelloWorld();
app.sayHi();
}
}
Note that this example runs the code in the main thread. To ensure that
we always run in a second thread, we have to slightly modify our example
to derive implement the Runnable interface. Then, we change our
main a bit to run the instance in a new thread.
public class HelloWorld implements Runnable {
public void run() {
System.out.println("Hello, world");
}
public static void main(String [] argv) {
HelloWorld app = new HelloWorld();
Thread t = new Thread();
t.run(app);
}
}
Note that all other platforms get their stack size limit from the shell, so
on Linux, Unix and Mac OS X, the user can simply use ulimit to
adjust stack size. As such, all the examples in this manual will
be written using the simpler, single-threaded approach.