打包和部署 Scala 应用程序 [英] Packaging and Deploying Scala Applications

查看:36
本文介绍了打包和部署 Scala 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打包 Scala 应用程序以在台式 PC 上使用的最简单方法是什么?我猜应该是 jar 文件的形式.

What is the simplest way to package a Scala application for use on a desktop PC? I'm guessing that would be in the form of a jar file.

目前我正在使用 SBT 编译和运行程序

At the moment I'm using SBT to compile and run programs

我对安装了 Scala(以及类路径中的库)的机器以及只有 Java 的机器的解决方案感兴趣.

I'd be interested in solutions for machines that have Scala installed (and the library in their classpath), as well as those that only have Java.

推荐答案

打包 Scala 应用程序最简单(也是最一致)的方法是打包到 JAR 中(就像使用普通 Java 应用程序一样).只要 JAR 由标准编译的 Java 类组成,您就可以运行Scala"JAR,即使您的机器上没有 Scala 运行时(您所需要的只是类路径中的 Java 运行时和 scala-lang.jar).您可以在清单中指定主类(应用程序功能的网关)

The simplest (and the most consistent) way to package a Scala application, is packaging into a JAR (like you do with normal Java applications). As long as JAR consists of standard compiled Java classes, you may run "Scala" JAR, even if you don't have Scala runtime at the box (all you need is a Java Runtime and scala-lang.jar on the classpath). You may specify the main class (gateway to functionalities of your application) in the manifast

Main-Class: mypackage.MyClass

这样您就可以调用它,只需将 JAR 名称传递给 java.exe.

so that you'll be able to call it only passing a JAR name to java.exe.

java -jar myjar.jar

您可以在指定主类SBT 项目定义.

You may specify the main class in SBT project definition.

这篇关于打包和部署 Scala 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆