Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala Swing package not found

My Problem:

error: object swing is not a member of package scala
import scala.swing._
^

When I try to start any GUI App with Scala. What I tryed up to now: call directly by the scala command, and precompile first by scalac and fsc, nothing works.

My System: an Ubuntu 11.10 Machine, with installed OpenJDK 6, OpenJDK 7, Oracle JDK 6 and the Scala-Packe from the Ubuntu Repositories, additionally I tryed the "new" Scala from the official Scala Homepage (scala-lang). The .deb-package fails to install, but the plain files from the *.tgz file works so far.

I tried every possible combination of those Software I have installed, no one works.

The Joke: on my Windows 7 Machine, the same code (dropbox-sync) works without any problems.

Any Ideas? Did I forget something?

like image 359
Maximilian Stroh Avatar asked Apr 20 '12 15:04

Maximilian Stroh


3 Answers

already many months since the original question, but since I just ran into the same, and googling showed this thread:

Looks like they separated scala swing from the core swing library. So if you're using sbt: libraryDependencies += "org.scala-lang" % "scala-swing" % "2.10.2"

(I guess the previous answers imply that as well, really, but since I got that error and this was the fix, I'm just adding it for others' reference).

like image 122
mat_dw Avatar answered Nov 06 '22 17:11

mat_dw


It is apparently not finding scala-swing.jar on the classpath. I'm not sure why this would be; it works on my system (still 11.04; don't like Unity). Try adding it explicitly: -cp /wherever/oneiric-ocelot/puts/scala/lib/scala-swing.jar.

If the file is not on your system, you can download it from the project webpage. (Click on the appropriate "latest release" buttons in the README, just under the title. Then download the jar.)

like image 30
Rex Kerr Avatar answered Nov 06 '22 17:11

Rex Kerr


the easiest way to resolve this error is to either download the scala.swing package and keep it in a folder called lib in your main project folder. this way when you compile the program uing sbt or any other tool the compiler will scan the lib folder and update itself with the new package. the other way is to edit the build.sbt file by adding the following line in it

"org.scala-lang" % "scala-swing" % "2.10.2"

like image 44
Kamlesh Avatar answered Nov 06 '22 19:11

Kamlesh