也可以从与斯卡拉文件创建jar文件 [英] Cannot run jar file created from scala file
问题描述
这是我已经写在斯卡拉code。
This the code that I have written in scala.
object Main extends App {
println("Hello World from Scala!")
}
这是我的 build.sbt 的
name := "hello-world"
version := "1.0"
scalaVersion := "2.11.5"
mainClass := Some("Main")
这是我跑创建的jar文件的命令。
This is the command that I have run to create the jar file.
sbt package
问题: HELLO-world_2.11-1.0.jar 的已在的目标/斯卡拉2.11 的创建了一个名为jar文件。但我不能运行该文件。这是给我一个错误说的的NoClassDefFoundError 的
Problem : A jar file named hello-world_2.11-1.0.jar has been created at target/scala-2.11. But I cannot run the file. It is giving me an error saying NoClassDefFoundError.
问:我在做什么错了?我希望我已经清楚我的问题。如果有一些混乱,那么请询问。先谢谢了。
Question : What am I doing wrong? I hope I have made my question clear. If there is some confusion then please ask. Thanks in advance.
推荐答案
它还说的什么的类没有找到。最有可能你是不包括斯卡拉-library.jar
。您可以运行 Scala的目标/斯卡拉2.11 / HELLO-world_2.11-1.0.jar
如果您有2.11斯卡拉可通过命令行或的java -cp<路径斯卡拉-library.jar>:目标/斯卡拉2.11 / HELLO-world_2.11-1.0.jar主
(使用; $ C $的c>来代替
:
在Windows上)
It also says what class is not found. Most likely you aren't including scala-library.jar
. You can run scala target/scala-2.11/hello-world_2.11-1.0.jar
if you have Scala 2.11 available from the command line or java -cp "<path to scala-library.jar>:target/scala-2.11/hello-world_2.11-1.0.jar" Main
(use ;
instead of :
on Windows).
这篇关于也可以从与斯卡拉文件创建jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!