Re: primer requested on exporting QuantLib to Java

Posted by Tito Ingargiola on
URL: http://quantlib.414.s1.nabble.com/primer-requested-on-exporting-QuantLib-to-Java-tp6137p6138.html


Hi,

Here are some quick notes on the steps you need to take in unix.  Windows also works, but I don't currently have a working windows quantlib env, so...

I hope it's helpful.  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!

[hidden email] wrote:
Can anyone tell me how to import QuantLib libraries into my Java development environment? I can't seem to locate any guides on getting this done.

Thanks for any instructions or references to instructions on this.

G





-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users