Initializing help system before first use

Adding the message callback in Java


Type: Adding callbacks
Rating: 1 (simple)
Description: The examples demonstrates how to define a messaging callback for the Xpress Optimizer in Java.
File(s): Callback.java


Callback.java
import com.dashoptimization.*;

class Callback implements XPRSmessageListener
{
    public void run ()
    {
        try {
            XPRSprob problem = new XPRSprob ();

            problem.setIntControl (XPRS.LPLOG, 1);
            problem.addMessageListener(this,null);

            problem.readProb ("javatest","");
            problem.lpOptimize ("");

            problem.removeMessageListener();
        } catch(XPRSprobException xpe) {
            xpe.printStackTrace();
        }
    }

    public void XPRSmessageEvent(XPRSprob prob,
        Object data, String msg, int len, int type)
    {
        if (msg != null) {
            System.out.println (msg);
        }
    }

    public static void main(String [] args)
    {
        try {
            XPRS.init ();
        } catch (Exception e) {
            System.out.println ("Failed to initialize");
            return;
        }

        try {
          Callback c = new Callback ();
          c.run ();

        } finally {
          XPRS.free ();
        }
    }
}

© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.