For my first attemp to use CP Optimizer with java, when i run my program i get this error message :
Exception in thread "main" java.lang.NoSuchMethodError: SwigDirector_IloIntValueEvalWrapper_eval
at ilog.cp.cppimpl.cp_wrapJNI.swig_module_init(Native Method)
at ilog.cp.cppimpl.cp_wrapJNI.<clinit>(cp_wrapJNI.java:802)
at ilog.cp.cppimpl.IloCP.<init>(IloCP.java:109)
at ilog.cp.IloCP.<init>(IloCP.java:128)
at ilog.cp.IloCP.<init>(IloCP.java:120)
at buffPos.main(buffPos.java:73)
Knowing that I included the needed libraries ILOG.CP.jar and oplall.jar in the library setting of my project in IntelliJ IDEA and also in the environment variable PATH of my windows. I'm using jdk 15.0.1
The part of my program using iloIntVar is :
// define new model
IloCP modelPos = new IloCP();
// variables
IloIntVar[][] x = new IloIntVar[ligne + 1][];
for (int i = 0; i < ligne + 1; i++) {
x[i] = modelPos.boolVarArray(colone + 1);
}
IloIntVar[][] a = new IloIntVar[ligne + 1][colone + 1];
2a) If it's static code: Try to see if classes have been loaded in the JVM (or even which class from which JAR lib). Ru your Java application with the - verbose option:
2b) Check in the Run Configurations which classes and libs have been configured. Maybe the lib is not included there (top right corner next to the green run triangle). 'edit configuration' and look into the classpath.
2c) It would be helpful to get an understanding if you use any package control system (Maven etc.)
3a) As there's JNI involved - make sure classes AND methods that are called are available as the "NoSuchMethodError" is throws in a method cannot be found in the JVM when called by JNI. Unfortunately not all infos is available in your snippet to debug your code. But it's very likely somethings called wrong here.