在java jar文件中运行scala程序

时间:2016-03-28 10:52:07

标签: eclipse scala

我正在尝试通过jar文件运行Scala程序。我创建了jar文件,但它无法在程序中找到主要方法。我在某处读到它无法找到Scala库所以我运行了下面的命令;但我收到以下错误:

[root@01HW394486 Desktop]# java -cp /opt/eclipse/plugins/org.scala-ide.scala210.jars_4.3.0.201512011535/target/jars/scala-library.jar -jar Test3.jar 
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$
    at TestDemo.funct1(MainClass1.scala:4)
    at MainClass1$.main(MainClass1.scala:10)
    at MainClass1.main(MainClass1.scala)
Caused by: java.lang.ClassNotFoundException: scala.Predef$
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 3 more

请帮忙......谢谢

1 个答案:

答案 0 :(得分:0)

尝试java -cp all-involvedjar-included-Test.jar3 mainClassPackageLocation
类似于:java -cp scala-library.jar:test-hello_2.10-0.1.0.jar com.salc2.Main