ForexConnectAPI issue: java.lang.NoClassDefFoundError

Moderator: Moderator

ForexConnectAPI issue: java.lang.NoClassDefFoundError

Postby Georgeh » Mon Apr 03, 2023 7:25 pm

Hi everyone,

I just followed the instruction to using ForexConnectAPI 1.6.5 and met a small issue.
Is there someone could help me to solve it.

IDE: Eclipse 2023-3
Language: Java JDK-19
Java.library.path: .;.\bin;C:\Program Files\Candleworks\ForexConnectAPIx64\bin\java;C:\Program Files\Candleworks\ForexConnectAPIx64\bin
Java class.path: C:\Users\guest\eclipse-workspace\Forex\bin
Java working directory: C:\Users\guest\eclipse-workspace\Forex
Add external JARs: C:\Program Files\Candleworks\ForexConnectAPI\bin\java\fxcore2.jar
Code:
public static void main(String[] args) {
O2GSession session = O2GTransport.createSession();
...
}

Issue: java.lang.NoClassDefFoundError: com/fxcore2/O2GTransport at Test.main(Test.java:28)

I tried same code in MacOS/Ubuntu/Win11 and med the same issue.
Below attached official instruction for Java API using from:
http://www.fxcorporate.com/help/Java/web-content.html#order2go2_Java.html


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:
Add fxcore2.jar to the libraries
In NetBeans: Libraries->Add JAR/Folder
In Eclipse: Project->Properties->Java Build Path->Libraries tab->Add External JARs
1.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")
3.Add: C:\Program Files\Candleworks\ForexConnectAPI\bin
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
4.Add: -Djava.library.path=.;./java
Add namespace com.fxcore2 to your project:
import com.fxcore2.*;


I followed the steps but it didn't work. Is there something i missed?

Kind regards,
George
Georgeh
 
Posts: 5
Joined: Sat Apr 01, 2023 3:32 am

Re: ForexConnectAPI issue: java.lang.NoClassDefFoundError

Postby Konstantin.Usanov » Fri Apr 21, 2023 7:04 am

Hi George,
Did u try adding ForexConnect API in Java classpath too, not only to librarypath? It's may by missed and follow to exactly the same error as u have.

Also u mention different paths of FC API for "Java.library.path" and "Add external JARs:"
C:\Program Files\Candleworks\ForexConnectAPIx64 and C:\Program Files\Candleworks\ForexConnectAPI
It may by root cause too for u issue.

Java.library.path: .;.\bin;C:\Program Files\Candleworks\ForexConnectAPIx64\bin\java;C:\Program Files\Candleworks\ForexConnectAPIx64\bin
Java class.path: C:\Users\guest\eclipse-workspace\Forex\bin
Java working directory: C:\Users\guest\eclipse-workspace\Forex
Add external JARs: C:\Program Files\Candleworks\ForexConnectAPI\bin\java\fxcore2.jar


It may be helpful as additional info:
The FC 1.6.5 Java docs available at next url
https://fxcodebase.com/bin/forexconnect ... ntent.html
Best regards,
Konstantin.
Konstantin.Usanov
FXCodeBase: Confirmed User
 
Posts: 47
Joined: Mon Aug 30, 2010 3:02 am
Location: Siberia, Omsk


Return to ForexConnect API

Who is online

Users browsing this forum: No registered users and 2 guests

cron