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

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

问题描述

在桌面PC上打包Scala应用程序最简单的方法是什么?我猜想这将是一个jar文件的形式。



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



我将对安装Scala的机器(和类路径中的库)以及只有Java的机器感兴趣。



谢谢。

解决方案

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

 主类:mypackage.MyClass 

,以便您只需将JAR名称传递给java.exe即可。

  java -jar myjar.jar 

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


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.

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

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.

Thanks.

解决方案

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

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

java -jar myjar.jar

You may specify the main class in SBT project definition.

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

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