Can't launch scala swing application in intellij idea 2017.2.4

Hi,

I'm trying to launch a swing scala swing application using the latest version of intellij idea (2017.2.4) and running into an error.

The error is:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1$class
at scala.swing.Reactions.<init>(Reactions.scala:44)
at scala.swing.Reactions$Impl.<init>(Reactions.scala:17)
at scala.swing.Reactor$class.$init$(Reactor.scala:20)
at scala.swing.SwingApplication.<init>(SwingApplication.scala:4)
at scala.swing.SimpleSwingApplication.<init>(SimpleSwingApplication.scala:13)
at net.tralfamadore.SimpleGUI$.<init>(SimpleGUI.scala:5)
at net.tralfamadore.SimpleGUI$.<clinit>(SimpleGUI.scala)
at net.tralfamadore.SimpleGUI.main(SimpleGUI.scala)
Caused by: java.lang.ClassNotFoundException: scala.Function1$class
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more

Process finished with exit code 1

 

I'm using an SBT based scala project (File -> New Project -> Scala -> SBT).

My build.sbt looks like this:

name := "scalaswingbusted"

version := "0.1"

scalaVersion := "2.12.4"

libraryDependencies += "org.scala-lang" % "scala-swing" % "2.11.0-M7"

 

The command line it uses to start the program looks like this:

C:\dev_inst\java8\bin\java "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.4\lib\idea_rt.jar=50931:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.4\bin" -Dfile.encoding=UTF-8 -classpath C:\dev_inst\java8\jre\lib\charsets.jar;C:\dev_inst\java8\jre\lib\deploy.jar;C:\dev_inst\java8\jre\lib\ext\access-bridge-64.jar;C:\dev_inst\java8\jre\lib\ext\cldrdata.jar;C:\dev_inst\java8\jre\lib\ext\dnsns.jar;C:\dev_inst\java8\jre\lib\ext\jaccess.jar;C:\dev_inst\java8\jre\lib\ext\jfxrt.jar;C:\dev_inst\java8\jre\lib\ext\localedata.jar;C:\dev_inst\java8\jre\lib\ext\nashorn.jar;C:\dev_inst\java8\jre\lib\ext\sunec.jar;C:\dev_inst\java8\jre\lib\ext\sunjce_provider.jar;C:\dev_inst\java8\jre\lib\ext\sunmscapi.jar;C:\dev_inst\java8\jre\lib\ext\sunpkcs11.jar;C:\dev_inst\java8\jre\lib\ext\zipfs.jar;C:\dev_inst\java8\jre\lib\javaws.jar;C:\dev_inst\java8\jre\lib\jce.jar;C:\dev_inst\java8\jre\lib\jfr.jar;C:\dev_inst\java8\jre\lib\jfxswt.jar;C:\dev_inst\java8\jre\lib\jsse.jar;C:\dev_inst\java8\jre\lib\management-agent.jar;C:\dev_inst\java8\jre\lib\plugin.jar;C:\dev_inst\java8\jre\lib\resources.jar;C:\dev_inst\java8\jre\lib\rt.jar;C:\Users\wreh\IdeaProjects\scalaswingbusted\target\scala-2.12\classes;C:\Users\wreh\.sbt\boot\scala-2.12.4\lib\scala-library.jar;C:\Users\wreh\.ivy2\cache\org.scala-lang\scala-swing\jars\scala-swing-2.11.0-M7.jar net.tralfamadore.SimpleGUI

 

The code I'm trying to run looks like this:

package net.tralfamadore

import scala.swing._

object SimpleGUI extends SimpleSwingApplication {
def top = new MainFrame {
title = "Hello, World!"
contents = new Button {
text = "Click Me!"
}
}

}

Thanks,

Bill
3 comments
Comment actions Permalink

Please zip and share the sample project to reproduce it: https://intellij-support.jetbrains.com/hc/articles/206869619.

What SBT version do you use?

Did you try current IntelliJ IDEA version from http://www.jetbrains.com/idea/download/index.html with the latest Scala plug-in version?

0
Comment actions Permalink

Hi Serge,

 

Thanks for your response.  I couldn't figure out how to attach a file to this ticket, so I made a new one: https://intellij-support.jetbrains.com/hc/en-us/requests/1132456 and attached the project I'm using.  I upgraded to Intellij 2017.2.5.  I believe I'm using the latest scala plugin (2017.2.13).  I'm using sbt version 1.0.3 and scala version 2.12.4.

 

Thanks,

 

Bill

0
Comment actions Permalink

Command line SBT shows the same error, looks like you should use the same Scala and scala-swing libraries. The issue is not related to IntelliJ IDEA.

0

Please sign in to leave a comment.