Scala NoClassDefFoundError related to Swing

I have a GUI class named Gui.scala and Eclipse does not show any errors directly in the scala file. My scala version is 2.11, and I manually added scala -swing-2.10.4.jar to my build path in Eclipse. If I do not, Eclipse complains that it does not find the Swing library.

The first lines of source code are as follows:

package filmreviews
import scala.swing._
import event._
import javax.imageio.ImageIO
import javax.swing.ImageIcon
import java.io.File
import java.awt.image.BufferedImage
import java.net.URI
import java.net.URL
import java.awt.Desktop
import java.awt.Cursor
import java.awt.Color
import javax.swing.border
import javax.swing.BorderFactory
import javax.swing.UIManager
object Gui extends SimpleSwingApplication {
    def top = new MainFrame {
        ...more code here...

I get the following error:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class

In addition, there is a long list that indicates where the error occurred in the code. Only lines referring to my own code:

at filmreviews.Gui$$anon$3.<init>(Gui.scala:17)
at filmreviews.Gui$.top(Gui.scala:17)
at filmreviews.Gui$.top(Gui.scala:16)

That is why I think this is due to the creation of the MainFrame object. This could also be due to the way I manually added the Swing library to the build path. However, I do not know what causes the error or how to fix it.

+4
1

Scala 2.11, scala -swing, 2.11. 2.10.4 2.11.

2.11- maven central.

, sbt:

libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "1.0.1"
+7

All Articles