I am trying to pack a small application (while still learning Scala!) In a "clean way". The goal is to have an executable JAR file. I have done the following:
- packaged JAR using sbt -> will work with
scala -cp myjarfile.jar MyClass
or
java -classpath path\to\scala-library.jar;myjarfile.jar MyClass
but will not work with
java -jar myjarfile.jar
because then scala / ScalaObject could not be found. And do not use adding classpath for this last one, since the -jar parameter will ignore the -classpath parameter. Note that I added scala libs to my system CLASSPATH variable, but it seems to be ignored when -jar is used.
- added the contents of the scala library (first unpacking them) to the jar created by sbt. Then it works (the jar can be double-clicked and launched), but the manipulation is somewhat long, and the resulting file has several megabytes. Not ideal.
After several hours of working on the Internet, I see no way to create a small jar file that will run when double-clicked and will not have painful manipulations. What am I missing? I suppose there must be some way to determine where the scala libraries are at the system level. How do you work with small applications that you want to compile and ready to work for better performance?
Note that although I use sbt, I don't have a tool for jar (I rely on the JRE, not the JDK).
Thanks! Pierric.
scala jar executable-jar
Pierric
source share