0

I am unable to use swing library with my scala-sdk-2.12.4. I am using Java 9 version. When I try to run the program:

package rs.ac.bg.etf.zd173013m.gui

import swing._

object HelloWorld extends SimpleSwingApplication {
def top = new MainFrame {
   title = "First Swing App"
    contents = new Button {
     text = "Click me"
   }
 }
}

I get the following error:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Method scala.swing.Reactor.$init$()V must be InterfaceMethodref constant
    at scala.swing.SwingApplication.<init>(SwingApplication.scala:4)
    at scala.swing.SimpleSwingApplication.<init>(SimpleSwingApplication.scala:13)
    at rs.ac.bg.etf.zd173013m.gui.HelloWorld$.<init>(Application.scala:5)
    at rs.ac.bg.etf.zd173013m.gui.HelloWorld$.<clinit>(Application.scala)
    at rs.ac.bg.etf.zd173013m.gui.HelloWorld.main(Application.scala)
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • http://central.maven.org/maven2/org/scala-lang/modules/ So the solution to this problem is to download the scala-swing _2.12.0-RC2 version. If somebody has an idea how to find the newer version (2.12.4 compatible with 2.12.4 SDK, I would be grateful). – Djordje Zivanovic Jun 17 '18 at 00:07

1 Answers1

1

You have incompatible JAR versions on your classpath. The code in the JAR containing "SwingApplication" was compiled against a different version of "Reactor" than the one on your classpath.

What are you using to manage your dependencies? I guess that you are downloading them manually.

Switch to a dependency management system like Gradle and this problem should go away, as it will ensure that all your dependencies are consistent.

Rich
  • 15,048
  • 2
  • 66
  • 119