我有一个非常简单的项目,其中包含.scala
文件,build.sbt
文件和/lib
文件夹,其中包含一个.jar
。我的scalaVersion设置为2.10.5(为了向后兼容),我运行sbt compile
,sbt下载.jars用于scala-2.10和scala-swing。所以看起来这部分正在发挥作用......
当我sbt run
时,我收到运行时错误:
[info] Running GuiProgramOne
[error] (run-main-0) java.lang.NoClassDefFoundError: scala/collection/GenTraversableLike$class
java.lang.NoClassDefFoundError: scala/collection/GenTraversableLike$class
at scala.swing.RefSet.<init>(Publisher.scala:167)
at scala.swing.Publisher$$anon$1.<init>(Publisher.scala:34)
at scala.swing.Publisher$class.$init$(Publisher.scala:34)
at scala.swing.Window.<init>(Window.scala:25)
at scala.swing.Frame.<init>(RichWindow.scala:77)
at scala.swing.MainFrame.<init>(MainFrame.scala:19)
at UI.<init>(UI.scala:3)
at GuiProgramOne$.main(UI.scala:11)
at GuiProgramOne.main(UI.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: java.lang.ClassNotFoundException: scala.collection.GenTraversableLike$class
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at scala.swing.RefSet.<init>(Publisher.scala:167)
at scala.swing.Publisher$$anon$1.<init>(Publisher.scala:34)
at scala.swing.Publisher$class.$init$(Publisher.scala:34)
at scala.swing.Window.<init>(Window.scala:25)
at scala.swing.Frame.<init>(RichWindow.scala:77)
at scala.swing.MainFrame.<init>(MainFrame.scala:19)
at UI.<init>(UI.scala:3)
at GuiProgramOne$.main(UI.scala:11)
at GuiProgramOne.main(UI.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
目录结构:
.
├── build.sbt
├── GUI.class
├── GUI$.class
├── lib
│ └── scala-swing-2.9.1.jar
├── project
│ └── target
│ └── config-classes
│ ...
├── target
│ └── streams
│ ...
└── GUI.scala
build.sbt:
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
scalaVersion := "2.10.5"
)),
name := "Game of Life",
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-swing" % "2.9.1"
)
)