Creating a stand-alone jar

I am starting again with Scala. I have created a simple project with Emacs (no IDE). What is the best way to create a stand-alone jar I can run with Java?

Using sbt, you can create a jar-file with the command package. To run it on command line with java, add the created jar file (and dependencies if any) as well as scala-library.jar (and scala-reflect.jar) to your classpath.

When you want to create a single fat jar-file that includes all the depencies, incl. the scala-library, add
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7")
to ./project/plugins.sbt

You can then use the sbt command assembly to generate a fat jar-file.
See more https://github.com/sbt/sbt-assembly

1 Like

That does what I want.
Thank you.

I do not remember the exact reasons, but i use https://github.com/xerial/sbt-pack