如何在终端中运行 Scala 程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/41229164/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run a scala program in terminal?
提问by Programmerr
I have created a .scala file in the Scala version of eclipse, it has a main and object. I want to somehow compile this possibly into a jar file, so I can run it from terminal?
我在 Eclipse 的 Scala 版本中创建了一个 .scala 文件,它有一个 main 和 object。我想以某种方式将它编译成一个 jar 文件,以便我可以从终端运行它?
any info will be appreciated.
任何信息将不胜感激。
Thanks, Rhys
谢谢,里斯
回答by evan.oman
Here is the full process from the command line:
以下是命令行的完整过程:
evan@vbox ~> cat test.scala
object test{
    def main(args: Array[String]): Unit = println("Hello!")
}
evan@vbox ~> scalac test.scala
evan@vbox ~> scala test
Hello!
However if you want to use Scala IDE to its full potential I would check out this tutorial.
但是,如果您想充分利用 Scala IDE,我会查看本教程。
回答by radumanolescu
To create the JAR, follow this:
要创建 JAR,请执行以下操作:
Then you can run it with
然后你可以运行它
java -cp /path/to/My.jar com.co.package.MyObj

