简体   繁体   中英

run scala program in java jar file

I am trying to run Scala program through a jar file. I created the jar file but it can't find the main method in the program. I read somewhere that it is unable to find the Scala library so I ran the command below; but I am getting the following error:

[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

Please help...Thanks

Try java -cp all-involvedjar-included-Test.jar3 mainClassPackageLocation
Something like: java -cp scala-library.jar:test-hello_2.10-0.1.0.jar com.salc2.Main

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM