我有一个简单的 scala 脚本,如下所示:
object SaveTaggedSenseTask {
def main(args: Array[String]) {
val reader:SenseEvalAllWordsDocumentReader = new SenseEvalAllWordsDocumentReader()
reader.parse(args(0))
println(reader.sentences)
reader.sentences()
}
}
这SenseEvalAllWordsDocumentReader
是一个 java 定义的类,它只是 SAX 解析器的包装器。调用句子应该简单地返回另一个名为 Sentence 的 java 定义类的 java List。如果我使用运行此代码
scala -cp jar-with-everything.jar SaveTaggedSenseTask.scala path/to/file.xml
我得到以下可怕的输出混乱:
java.lang.ClassNotFoundException: Main (args = /home/stevens35/senseEval/senseEval3-allwords/english-all-words.xml, classpath = /tmp/scalascript7300484879512233483.tmp:/usr/java/jdk1.6.0_26/jre/lib/resources.jar:/usr/java/jdk1.6.0_26/jre/lib/rt.jar:/usr/java/jdk1.6.0_26/jre/lib/jsse.jar:/usr/java/jdk1.6.0_26/jre/lib/jce.jar:/usr/java/jdk1.6.0_26/jre/lib/charsets.jar:/home/stevens35/devel/src/scala-2.9.1.final/lib/jline.jar:/home/stevens35/devel/src/scala-2.9.1.final/lib/scala-compiler.jar:/home/stevens35/devel/src/scala-2.9.1.final/lib/scala-dbc.jar:/home/stevens35/devel/src/scala-2.9.1.final/lib/scala-library.jar:/home/stevens35/devel/src/scala-2.9.1.final/lib/scalap.jar:/home/stevens35/devel/src/scala-2.9.1.final/lib/scala-swing.jar:/usr/java/jdk1.6.0_26/jre/lib/ext/sunjce_provider.jar:/usr/java/jdk1.6.0_26/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.6.0_26/jre/lib/ext/localedata.jar:/usr/java/jdk1.6.0_26/jre/lib/ext/dnsns.jar:/home/stevens35/devel/C-Cat/wordnet/.:/home/stevens35/devel/C-Cat/wordnet/target/extendOntology-wordnet-1.0-jar-with-dependencies.jar:/home/stevens35/devel/C-Cat/wordnet/../data/target/extendOntology-data-1.0.jar)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:103)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$runCompiled(ScriptRunner.scala:171)
at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:157)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.util.package$.waitingForThreads(package.scala:26)
at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:130)
at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:201)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:58)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
我假设这意味着 scala 正在寻找一些名为 Main 的类并且找不到它,但我不明白为什么它甚至会考虑寻找这个。此外,如果我删除该reader.sentences()
行,或对其进行调用size()
之类的操作,问题就会消失。我只能猜测 scala 以某种方式推断由于这个调用应该存在一个名为 Main 的类,但我没有看到任何明显的解决方法。
想法?任何帮助是极大的赞赏。