How to include ForexConnect API in Java

Brief

The article discusses how to include ForexConnect API in Java application.

Details

Let's say ForexConnect API is installed to C:\Program Files\Candleworks\ForexConnectAPI.
To include ForexConnect API in your Java application, you should:

  1. Add fxcore2.jar to the libraries
    In NetBeans: Libraries->Add JAR/Folder
    In Eclipse: Project->Properties->Java Build Path->Libraries tab->Add External JARs
    Add: C:\Program Files\Candleworks\ForexConnectAPI\bin\java\fxcore2.jar

  2. Change working directory
    In Netbeans: Run->Working Directory
    In Eclipse: Project->Properties->Run/Debug Settings->New->(Select Configuration Type)->Main tab (Pick the main class)->Arguments tab->Working Directory (click "Other")
    Add: C:\Program Files\Candleworks\ForexConnectAPI\bin

  3. Send java.library.path to Java VM
    In Netbeans: Project->Properties->Run->VM options
    In Eclipse: Project->Properties->Run/Debug Settings->(pick up configuration you just created)->Arguments tab->VM arguments
    Add: -Djava.library.path=.;./java

  4. Add namespace com.fxcore2 to your project:
    import com.fxcore2.*;

back