Packaging and Deploying Scala Applications

10,654

Solution 1

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.

Solution 2

http://www.scala-sbt.org/sbt-native-packager/index.html

The plugin allows you to package in a variety of formats(zip, tar, deb, dmg, msi, etc) and in different archtypes.

Share:
10,654
se681268
Author by

se681268

I get computers 'putin.

Updated on June 03, 2022

Comments

  • se681268
    se681268 almost 2 years

    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.

  • se681268
    se681268 almost 14 years
    I managed to get this far using the "package" command in SBT. I don't suppose you know how to include scala-library.jar in the resulting jar file?
  • Vasil Remeniuk
    Vasil Remeniuk almost 14 years
    Put the JAR into src/main/resources, and add it to the classpath -->> override val manifestClassPath = Some("scala-library.jar")
  • Vasil Remeniuk
    Vasil Remeniuk almost 14 years
    However, even if you package scala-library.jar into your app jar, it won't be bootstrapped by the classloader. In order to make the manifest update I mentioned above work, you will have to put scala-library.jar to the same folder with your jar.
  • mlg
    mlg about 9 years
    @SimonMorgan: coming half a year late, but may be useful for others: you may want to try this plugin for including dependencies in the jar: github.com/sbt/sbt-assembly