Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

packToJfx does not work
 Post subject: packToJfx does not work Post rating: 0   New post Posted: Sun 21 Jun, 2015, 12:47 
User avatar

User rating: 0
Joined: Thu 13 Mar, 2014, 17:17
Posts: 13
Location: Hungary,
Hi,

I cannot get packToJfx to work. I am trying to use it to convert a compile strategy (a jar file) into jfx format. I use the latest Dukascopy api (2.12.15) and dds2 (2.45.2) libraries with a demo account. Still, nothing seems to happen, no jfx file shows up in the directory of the jar file as it ought to, according to the specs. Any idea what is going wrong?

Here is the java code I use:

___________________________________________________________________
package compile;
import com.dukascopy.api.system.*;
import java.io.File;

public class Compile {
private static String jnlpUrl = "https://www.dukascopy.com/client/demo/jclient/jforex.jnlp";
private static String userName = "DEMO2gx...";
private static String password = "...";
private static IClient client;
public static void main(String[] args) throws JFAuthenticationException, JFVersionException, Exception {
try {client = ClientFactory.getDefaultInstance();
} catch (InstantiationException e) {System.err.println("getDefaultInstance problem" + e);}
client.connect(jnlpUrl, userName, password);
for (String s: args) {
System.out.println("Converting file " + s);
File ffile = new File(s);
client.packToJfx(ffile);
}
System.out.println("Done converting files.");
client.disconnect();
}
}
___________________________________________________________________


and the java output when the code is run:

...a lot of warnings skipped before connection is established.

2015-06-20 19:56:18.757 INFO ClientConnector - Primary connect successfull, primarySession is [MinaIoSessionWrapper [session=(SOCKET, R: d-ja-gva-91-142.dukascopy.com/194.8.15.142:10443, L: /192.168.1.3:49120, S: d-ja-gva-91-142.dukascopy.com/194.8.15.142:10443)]], address is [d-ja-gva-91-142.dukascopy.com/194.8.15.142:10443]
2015-06-20 19:56:19.300 INFO GreedClientAuthorizationProvider - !!!:Thread[ClientConnector,5,main]
2015-06-20 19:56:19.993 WARN WLabelData - White Label Image is not received
Converting file /home/ataman/work/trading/jforex/strategies/target/jfxchart-0.1.0-SNAPSHOT-standalone.jar
Done converting files.
2015-06-20 19:56:20.428 INFO ClientConnector - Child session opened for [d-ja-gva-91-142.dukascopy.com/194.8.15.142:10443]
2015-06-20 19:56:25.077 INFO ClientProtocolHandler - Disconnect task in queue, reason [CLIENT_APP_REQUEST], server address [d-ja-gva-91-142.dukascopy.com/194.8.15.142:10443], transport name [null]
Exception in thread "(1883008430) Client listeners invocation thread - 15" java.lang.NullPointerException

...a lot of warnings and an exception skipped after disconnecting from server.

___________________________________________________________________

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


 
 Post subject: Re: packToJfx does not work Post rating: 0   New post Posted: Tue 07 Jul, 2015, 12:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
There must be a cycle after call to IClient.connect() waiting for actual connect.
IClient.packToJfx() method must create jfx file or throw exception.
Provide full program execution log, please.

package compile;

import com.dukascopy.api.system.*;
import java.io.File;

public class Compile {
    private static String jnlpUrl = "https://www.dukascopy.com/client/demo/jclient/jforex.jnlp";
    private static String userName = "username";
    private static String password = "password";
    private static IClient client;

    public static void main(String[] args) throws JFAuthenticationException, JFVersionException, Exception {
        try {
            client = ClientFactory.getDefaultInstance();
        } catch (InstantiationException e) {
            System.err.println("getDefaultInstance problem" + e);
            System.exit(1);
        }

        client.connect(jnlpUrl, userName, password);

        //wait for it to connect
        int i = 10; //wait max ten seconds
        while (i > 0 && !client.isConnected()) {
            Thread.sleep(1000);
            i--;
        }
        if (!client.isConnected()) {
            System.err.println("Failed to connect Dukascopy servers");
            System.exit(1);
        }

        for (String s: args) {
            System.out.println("Converting file " + s);
            File ffile = new File(s);
            client.packToJfx(ffile);
        }
        System.out.println("Done converting files.");

        Thread.sleep(3000);
        client.disconnect();
        System.exit(0);
    }
}


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com