Reputation: 443
I have a scala project that I can run with sbt. Now I want to execute it as a stand alone app. How can I run it with the scala command and ensure the right version of everything, in particular the scala-library and JVM?
PS: Just to clarify what I mean by an example from ruby. I write some ruby script which I use routinely. For example, to apply updates a bit more cleanly then the OS does.
When I wrote the script I used ruby 1.8.3. ( Making version numbers up here as an example. ) I used the command line ruby my_script
.
Now the version is ruby 2.0.1. The script will not run under this ruby because of language changes. So I use the command line ruby1.8.3 my_script
.
Or rather I embed it in the shebang line.
Simalarly I want to run a jar using scala my_jar.jar
but it was a built using a scala version 2.8.3 and will not run with that command. How do I make scala use the right version?
Upvotes: 1
Views: 137
Reputation: 8996
Two things you can try here:
1) The sbt-native-packager will create an executable. For example, you can create an RPM or Debian package.
2) You can create an "uber jar" using (say) sbt-assembly and package all your dependencies into a fat jar. You can specify a main function to be executed when running the jar (using the JVM java -jar a-jar-to-execute.jar
command).
Both of the above are very active and widely used SBT plugins.
After your create the jar everything is in byte-code and you don't need to worry about Scala versions at that point. It will run as long as the Java (jvm) versions are compatible.
Upvotes: 1