Hi,
The swig files way works fine though setting it up is a bit of a steep
curve. I don't think jquantlib ever got real traction, but
I'm not sure as the swig bindings are swell for my needs. I had
written a blog entry describing the process which the quantlib page
links to but, as luck would have it, I imprudently toasted my blog
yesterday in the wee hours and it's going to take me at least a few
days to get it back up... below you'll find a quick outline of the
steps you need to take. Regards,
Tito.
--
Using Quantlib from Java (on linux)
1. Build Quantlib
- requires working version of boost
- ideally, this will just require:
sh
autogen.sh
./configure
make
sudo make install
2. Build Quantlib-SWIG
- requires working version of swig
- ideally, this will just require:
sh autogen.sh
./configure --with-jdk-include=${JAVA_HOME}/include
\
--with-jdk-system-include=${JAVA_HOME}/include/linux
make -C Java
sudo make -C Java install
3. Now you'll have a file named /usr/local/lib/QuantLib.jar. This needs to be added to your classpath.
4. Programs which call QuantLib functionality will need to have the LD_LIBRARY_PATH set. This can be done by invoking the vm with something like: -Djava.library.path=/usr/local/lib.
5. Programs which call QuantLib functionality will also
need to explicitly load the Quantlib libraries. This can be done with something like the following static block appearing before your main method:
static { // Load QuantLib
try { System.loadLibrary("QuantLibJNI");
}
catch (RuntimeException e) { e.printStackTrace(); }
}
6. Test your configuration by running the examples in Quantlib-SWIG/Java/examples.
It's worth understanding how Quantlib is being used from java.
SWIG is creating a JNI interface into those methods within Quantlib which have been exposed through their declaration in the swig *.i files. These files are found in Quantlib-SWIG/SWIG and they determine what functionality from Quantlib will be available to you. You'll likely need to get familiar with a subset of those files that you care about. If you find that some functionality you care about isn't exposed in those files, you may need to expose it yourself. There's a learning curve, but it's worth traversing so you can get at all the rich functionality so many smart people have put together.
All of this can be done on windows and I had once done it with mingw, but the process was painful (for me, at least, as I'm not a windows guy). That said, I did manage to get it to work and it had all the functionality I enjoyed under linux. Good luck!