Package and distribute a Scala jar to run on the command line

Add this to pom.xml – (update the mainClass to match your program):


In Eclipse right click project and run as Maven build with goal=package

Sample output for a project in D:\06repo Eclipse workspace:
Building jar: D:\06repo\testJar\target\testJar-0.0.1-SNAPSHOT.jar
Creates lib directory under testJar\target directory.

Execute the jar file.

D:\06repo\testJar\target>java -jar testJar-0.0.1-SNAPSHOT.jar

Hello World!

Zip the jar file along with the lib directory.

D:\06repo\testJar\target>f:\7-Zip\7z a -tzip testJar-0.0.1-SNAPSHOT.jar lib
Copy the zip file to a client that has Java installed.

D:\06repo\testJar\target>cp d:/tmp

Extract the zip file in the new client location.
d:\tmp>f:\7-Zip\7z x
Run the jar file in the new client location.

d:\tmp>java -jar testJar-0.0.1-SNAPSHOT.jar

Hello World!

Stack Overflow Article: