8

我正在使用 Scala 2.9.2。

运行 Scala 并测试一个简单的代码,这段代码是…… OK:

...
val title = "Hashing file (%s)..." format sizeToStr(file.length)

但是我不明白什么是什么,当我将该代码放入一个简单的应用程序中时,编译OK,在运行时它会抛出这个:

java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
        at group.pals.penguin.app.shasher.Shasher$.calcHash(shasher.scala:119)
        at group.pals.penguin.app.shasher.Shasher$.main(shasher.scala:76)
        at group.pals.penguin.app.shasher.Shasher.main(shasher.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
        at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
        at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
        at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
        at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
        at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
        at scala.tools.nsc.JarRunner$.run(MainGenericRunner.scala:16)
        at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
        at scala.tools.nsc.JarRunner$.runAndCatch(MainGenericRunner.scala:16)
        at scala.tools.nsc.JarRunner$.runJar(MainGenericRunner.scala:28)
        at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:78)
        at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

你能帮帮我吗?谢谢。

4

1 回答 1

13

似乎您正在编译的标准库版本与运行时使用的标准库版本不同。

于 2012-10-27T19:36:31.570 回答