How to run your program using SBT with command line arguments

There are two possible ways to pass command line arguments to your application when running it with SBT. The first one is to run it inside the SBT shell, and second, from your operating system terminal. They are slightly different, but let’s look at both of them.

SBT shell

In order to , you need first to execute sbt command from your project directory. Then just add parameters after run command.

sbt:MyTestProject> run param1 param2 param3

OS shell

When you want to run it from your OS shell, you need to enclose run command with parameters in quotes, just like this:

$ sbt "run param1 param2 param3"

That’s it! As you can see it’s pretty simple. And you have any questions, please, let me know in the comments below!