Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a jar from some Scala source code?

How can I create a jar from some Scala source code? I want to use some of that code in a Clojure project of mine.

Is there a simpler way than doing batch files as in this SO question?

Thanks, Alex

like image 512
Alex Baranosky Avatar asked Dec 12 '22 20:12

Alex Baranosky


1 Answers

Scala is in no way special when it comes to what you do with the .class files produced by its compiler. Just use the jar command with the c action flag.

However, you will need to have the scala-library.jar file in the class-path when you run the program that uses the Scala-compiled .class files. And be careful to use the scala-library.jar for / from the same Scala Development Kit that you used to compile the Scala source. As of yet, there isn't inter-version binary compatibility for Scala-generated .class files.

like image 164
Randall Schulz Avatar answered Jan 09 '23 04:01

Randall Schulz