LIVE mode

JForex SDK LIVE mode

All JForex-SDK project example programs are written to work in DEMO mode. In order for them to use the LIVE mode, one needs to do the following code adjustments:

Processing of captcha image

Consider the following program which processes the user inputs according to the captcha image:

public class MainPin {

    private static final Logger LOGGER = LoggerFactory.getLogger(MainPin.class);

    // url of the LIVE jnlp
    private static String jnlpUrl = "";
    // user name
    private static String userName = "";
    // password
    private static String password = "";

    private static IClient client;

    public static void main(String[] args) throws Exception {
        // get the instance of the IClient interface
        client = ClientFactory.getDefaultInstance();"Connecting...");
        // connect to the server using jnlp, user name and password
        client.connect(jnlpUrl, userName, password, PinDialog.showAndGetPin());

        //add here waiting on client.isConnected()

        //add here subscription to instruments and strategy launching

    private static class PinDialog extends JDialog {

        private final JTextField pinfield = new JTextField();
        private final static JFrame noParentFrame = null;

        static String showAndGetPin() throws Exception{
            return new PinDialog().pinfield.getText();

        public PinDialog() throws Exception {            
            super(noParentFrame, "PIN Dialog", true);

            JPanel captchaPanel = new JPanel();
            captchaPanel.setLayout(new BoxLayout(captchaPanel, BoxLayout.Y_AXIS));

            final JLabel captchaImage = new JLabel();
            captchaImage.setIcon(new ImageIcon(client.getCaptchaImage(jnlpUrl)));


            JPanel buttonPane = new JPanel();

            JButton btnLogin = new JButton("Login");
            btnLogin.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {

            JButton btnReload = new JButton("Reload");
            btnReload.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    try {
                        captchaImage.setIcon(new ImageIcon(client.getCaptchaImage(jnlpUrl)));
                    } catch (Exception ex) {
              , ex);
            getContentPane().add(buttonPane, BorderLayout.SOUTH);

The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.