In the previous post about creating an executable jar from your Scala code, I showed how to create the jar using your favourite compression software.
Today, you’ll see how to do it using jarjar. jarjar can be used to package all of your jars into a single one, thus eliminating external dependencies.
The great part is that it has an ant task, so I’ll show you how to use that:
<project name="jarjar tester"> <target name="jrjr"> <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="jarjar-1.0.jar" /> <jarjar destfile="jrjarilo.jar" manifest="Manifest.mf"> <zipfileset src="scala-library.jar" /> <fileset dir="."> <include name="*.class" /> </fileset> </jarjar> </target> </project>
You need to supply it with a manifest, so, you could use the one from here. You need to adjust the paths to your scala-library.jar and to jarjar.jar, and to specify the name you’d like your jar to receive.
If everything goes well ( and it should ), after running this target you should have your own executable jar, containing the Scala runtime.