5

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?

3 Answers 3

18

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).

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

Comments

4

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.)

7 Comments

@Hisako - That's strange. Try _root_.scala.swing._? You don't have something else shadowing the scala name do you?
nope, shadowing should not be the problem, scala itself works fine. root doesn't work, through.
checked again that nothing in /usr/bin, /usr/local, ... is shadowing scala, also went through my $PATH, nothing there. Then I installed again the Scala package from the Ubuntu SOurces. No Solution up to now. :(
@Hisako - Try using global search for "scala-swing.jar" (locate "scala-swing.jar")
@Hisako - I don't know what else to suggest, other than to reiterate that it must not be finding scala-swing.jar. I have no idea why. (Unicode in the path name that isn't handled properly?) Put some other jar next to scala-swing.jar and see if you can load anything from it, perhaps?
|
1

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"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.