Cannot import binance-api-client into JavaFX Application

534 Views Asked by At

I have a JavaFX project.

Ive installed a dependency for the binance-api-client package. Its in my dependencies folder

<dependencies>
   <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>13</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>13</version>
    </dependency>
    <dependency>
        <groupId>com.binance.sdk</groupId>
        <artifactId>binance-client</artifactId>
        <version>1.0.8-SNAPSHOT</version>
    </dependency>
</dependencies>

However, when I go to import it it.

import com.binance.client.*;

It says

  package com.binance.client is not visible

If I then follow the Netbeans advice to "Add Module to ModuleInfo". I get this in the module info.

module com.mycompany.btrade {
   requires javafx.controls;
   requires javafx.fxml;
   requires binance.api.client;
   opens com.mycompany.btrade to javafx.fxml;
   exports com.mycompany.btrade;

}

However then when I run the program, it just crashes, with this error

java.lang.module.FindException: Module binance.api.client not found, required by com.mycompany.btrade

Why can't I seem to import this package.

1

There are 1 best solutions below

4
On

I'm not sure if you're trying to use binance-java-api, which is what you want if you're working solely with Java, or if there actually is some other package that exists called com.binance.sdk.

From the documentation I looked at, your dependency should read:

    <dependency>
        <groupId>com.binance.api</groupId>
        <artifactId>binance-api-client</artifactId>
        <version>1.0.8-SNAPSHOT</version>
    </dependency>

That being said, I'm not certain if that versioning will still work if you make that change, but this would explain the error stating:

binance.api.client not found, required by com.mycompany.btrade

as it doesn't match the package described by the dependency.