Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  ILOG Java interface & swing

    Posted 05/10/13 11:19 AM

    Originally posted by: CedricVB


    Hello,

    To make my models a bit easier to work with, I'd like to spice them up with confirmation dialogs/alerts. Since this functionality wasn't available in the javascript API, I wanted to interface my CPLEX model with Java. 

    I've got the following code:

     

    package vrp;
    import javax.swing.*;
    import ilog.opl.*;
     
    public class Extensions {
    private JFrame frame = new JFrame();
     
    public Extensions() {
    frame.setSize(400,400);
    frame.setVisible(true);
    }

    The file loads correctly, I'm able to execute functions from my OPL file, but the window isn't shown (though it is when I try to execute the classfile directly).
    Any idea if it is possible to do this?

    Kind regards,

    Cedric


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: ILOG Java interface & swing

    Posted 05/10/13 11:49 AM

    Originally posted by: rdumeur


    Hi Cedric,

     

    Unfortunately, your code seems truncated. Could you please repost it as an attachment?

    Thank you in advance,

     

    Cheers,


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: ILOG Java interface & swing

    Posted 05/13/13 05:51 PM

    Originally posted by: CedricVB


    Hello :)

    Actually, that's all of the Java code (except for the closing bracket). 

    In my CP mod file I've got the following:

    using CP;
    execute {
        IloOplImportJava("java/Extensions.jar");
        var obj = IloOplCallJava("vrp.Extensions", "<init>", "");
    }

    Execution "blocks" right after the init, which I would interpret as the GUI running in the same thread as the execution thread, but still no window is shown. (Note: everything non-GUI related works just fine.)


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: ILOG Java interface & swing

    Posted 05/14/13 04:33 AM

    Originally posted by: FredericDelhoume


    Hi,

    Your code works fine on my machine, in  OPL IDE the window opens and stays there, running with oplrun the window appears then closes because execution ends.

     

     

     


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: ILOG Java interface & swing

    Posted 05/14/13 02:07 PM

    Originally posted by: CedricVB


    Apparently the problem is Java VM-related... Not sure exactly why that is and it is working for Frederic though.
    It now works when supplying a different java VM as startup parameter for the IDE.

    -vm "C:\Program Files\Java\jdk1.7.0_07\jre\bin"

    Now able to make confirmation dialogs! Awesomeness :)


    #CPOptimizer
    #DecisionOptimization