0

.scalaファイル、build.sbtファイル、および/lib単一のフォルダーで構成される非常に単純なプロジェクトがあります.jar。私の scalaVersion は 2.10.5 (下位互換性のため) に設定されており、実行sbt compileすると、sbt は scala-2.10 と scala-swing の .jar をダウンロードします。その部分は機能しているようです...

私がそう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"
    )
  )

コード: http://otfried.org/scala/index_28.html

4

1 に答える 1