JaCoP in Scala

  • Sylvain

    Sylvain - 2011-12-28

    I downloaded all the JaCoP available files recently (that is, JaCoP 3.1.1). I tested on Java and the examples are working fine.
    I then tried to compile the Scala version but I didn't manage to get it work yet. The following command line:

    <scala-2.9.1_dir>/bin/scalac -classpath scalaJaCoP/JaCoP-3.1.1.jar scalaJaCoP/*.scala

    gives me the following error:

    error: error while loading GCC, Missing dependency 'class java.util.ArrayDeque', required by scalaJaCoP/JaCoP-3.1.1.jar(JaCoP/constraints/GCC.class)
    scalaJaCoP/globals.scala:63: error: JaCoP.constraints.GCC does not have a constructor
        val c = new GCC( x.asInstanceOf[Array[JaCoP.core.IntVar]], y.asInstanceOf[Array[JaCoP.core.IntVar]] )

    It seems like an error with the JVM version. Is it working this way because the JaCoP jar file was compiled using Java 1.5? Or did I do something wrong?
    I then tried to compile the JaCoP source files myself, but it didn't work either because of library dependencies. Do you have any Makefile to help me in this task?
    I am working on Linux (Ubuntu) 64 bits, Java 1.6 and using Scala 2.9.1.


  • kris

    kris - 2011-12-28


    java.util.ArrayDeque has been introduced in Java since version 1.6. Are you sure you use Java 1.6?

    The other problem might be a path to JaCoP-3.1.1.jar. Do you have it in directory scalaJaCoP?

    Best regards,

  • Radoslaw Szymanek


    Are you sure that your Scala compiler is using Java 1.5? It looks like it is using an Java 1.5 thus the problem with ArrayDeque class. You can write a small test program in Scala that uses ArrayDeque and see if it compiles.

    The source code for JaCoP is also available so you can always work with source code. We use Java 1.6 and we do not use any fancy switches when generating the library, so I think the problem lies with your Scala compiler.


  • Sylvain

    Sylvain - 2011-12-29

    Thanks for your help, I did it after hours of struggle!
    It was a conflict caused by the JVMs that are installed on my machine. The scalac command needed a classpath pointer to Java 1.6 (then it compiled), but for some reason, at runtime the scala command was using my Java 1.5 (even after setting the update-alternative, the JAVA_HOME, etc.). I only forced scala to use Java 1.6 by executing the following command:

    env JAVACMD=<path_to_java1.6> scala [...]

    and finally it worked.


  • kris

    kris - 2011-12-29

    Good! Please, feel free to ask question regarding scala wrapper. BTW, you can find examples at http://hakank.org/jacop/jacop_scala.html

    Best regards,

  • Sylvain

    Sylvain - 2011-12-30

    Thank you very much. I am discovering both JaCoP and scala, and it is a very good challenge for me to work with both at the same time! I already found the example link you mentionned and for sure they will be of great help for me. Just for confirmation, there isn't any documentation for this scala wrapper, is there?
    Should I run into more troubles, I will ask for help in this forum.
    Thanks again,


  • kris

    kris - 2011-12-30

    Sorry, but there is no documentation yet. It is still experimental implementation. Of course, please ask question and I will try to answer and help.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks