Alex Rivera | Logout

Export Scala application to runnable JAR

Asked 2011-11-09T12:00:09.210
12

Can you tell me, if this is possible, how to export a Scala application to a normal runnable JAR that can run directly in the JVM ?
Thanks

Edit
Report

1 Answer

15

It is perfectly possible, see for instance this: running a maven scala project. Since Scala compiles to Java bytecode, JVM is not even aware of the underlying implementation language.

In essence after compiling Scala sources using scalac you will get a bunch of .class files which you can later package into a JAR. Then you can simply run them using:

$ java -cp "your.jar:scala-library.jar" com.example.Main

Note that you must include scala-library.jar on the CLASSPATH (currently it is almost 9 MiB...) and specify class containing main method.

answered 2011-11-09T12:03:37.287

Your Answer