Running a "main(args: Array[String])"

You must have a well define project, and it must compile your code successfully before (see Compiling ).


So you can now run your scala app by defining the "mainClass" property :

mvn scala:run -DmainClass=org.example.MyClass

Using Launcher

You need to use launchers if you :

  • need to specify args and/or jvmArgs that are different from the main configuration
  • run and run again the same "configuration"/command line
  • want to store, some configuration for later user, or for sharing with other
          <!-- args are optional -->
          <!-- jvmArgs are optional -->
        <!-- you could define other launcher -->

Now you can run the following command to run your launcher (the classpath used is the test classpath).

mvn scala:run -Dlauncher=foo

If you don't specify launcher or mainClass then the first launcher is used, in your case, the example below is equivalent to the example above.

mvn scala:run

If you need/which to specify some additional arguments at call time use "-DaddArgs=arg1|arg2|arg3" ('|' is used as separator)

Set the property 'displayCmd' to true, to display the command line used