5

I've tried to use scala.swing package, but it can't be found. The compiler (2.9.1) says "swing is not a member of scala". Any ideas? Everything else seems working Ok, I haven't experienced any problems with other Scala packages.

10
  • 1
    Have you included swing as a dependency? Commented Jan 26, 2012 at 20:51
  • No. Isn't it a part of the standard library? Isn't everything under scala namespace always included by default? Commented Jan 26, 2012 at 20:55
  • If not, then what exactly am I to add to my project dependencies? Commented Jan 26, 2012 at 21:04
  • in lib/ directory in the place where your Scala distribution is installed you should have scala-compiler.jar, scala-library.jar, some other jars and scala-swing.jar. Check it and maybe check your paths. Commented Jan 26, 2012 at 21:07
  • Not quite sure, but last time I've developed swing app under scala I added dependency as "org.scala-lang" % "scala-swing" % "2.9.0-1". Somebody could clarify, if swing part of scala standart lib or not. Commented Jan 26, 2012 at 21:07

1 Answer 1

13

So, to wrap up the solution. First of all you need to define dependency on swing library. Add the following to your build.sbt file:

libraryDependencies += "org.scala-lang" % "scala-swing" % "2.9.0-1" 

If you're using Intellij IDEA, with sbt-idea plugin, invoke gen-idea to rebuild project to let IDEA know about swing.

Sign up to request clarification or add additional context in comments.

2 Comments

"2.9.1" instead of "2.9.0-1" in my case.
You can use scalaVersion.value instead of hard-coding a Scala version here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.