Mark Volkmann: Using SWIG reduces the amount of manual coding required to invoke C/C++ functions from other programming languages. In the case Java, JNI can be used directly, but this requires a large amount of tedious coding. Another benefit of using SWIG is that it is less error prone than manual coding. Correct use of JNI is complicated, especially for passing non-primitive types.
I think SWIG is something that is underreported and underutilized in the Java community. And it is a very useful thing. It promotes reuse and cuts down on the number of wheels that you have to reinvent.
Aside from a couple of minor problems caused by smart dashes and location differences between i386 and x86_64, the sample run fine, both the Java and the Ruby version, on my newly built Fedora Core 4 AMD64 box:
[weiqi@gao] $ ./running-swig-for-java
[weiqi@gao] $ ./running-the-java-application
Mark Volkmann is 44 years old.
Amanda Volkmann is 20 years old.
Mark Volkmann is older than Amanda Volkmann? true
And I haven't even installed the Sun JDK yet. ( Fedora Core 4 users are advised not to use the Java RPM provided by Sun.) I'm running with the Free Java (a mix of gcj, GNU Classpath, and Eclipse) that comes on the Fedora Core 4 CDs.