My project has a few executables. How may we run one of them with supplied command line arguments ? After attempting to include the args from sbt run they are ignored and instead the menu of available main's are listed:
C:\apps\simpleakka>sbt run "com.mycompany.sparkpoc.hbase.HBasePop spark://localhost:7088 localhost:2181 1000 100"
[info] Loading project definition from C:\apps\simpleakka\project
[info] Set current project to simpleakka (in build file:/C:/apps/simpleakka/)
Multiple main classes detected, select one to run:
[1] com.mycompany.sparkpoc.LCS
[2] com.mycompany.sparkpoc.rdd.HBaseMR
[3] org.apache.spark.examples.HwHBaseTest
[4] com.mycompany.sparkpoc.rdd.HBaseMROld
[5] com.mycompany.sparkpoc.HBaseTest
[6] com.mycompany.sparkpoc.SocketServer
[7] com.mycompany.sparkpoc.hbase.HBasePop
But by selecting one of the seven options, the command line args are lost:
Enter number:
Invalid number: java.lang.NumberFormatException: For input string: ""
java.lang.RuntimeException: No main class detected.
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) No main class detected.
[error] Total time: 3 s, completed Jun 25, 2014 6:12:07 PM
You can pass straight from the command line, just by enclosing between quotes, like this:
$ sbt "runMain com.mycompany.sparkpoc.hbase.HBasePop spark://localhost:7088 localhost:2181 1000 100"
If you want to run a specific main class, you can use runMain
, and to pass command line arguments you have to specify them after the main class name.
> help runMain
Runs the main class selected by the first argument, passing the remaining arguments to the main method.
For example
> runMain sample.hello.Main firstArg secondArg thirdArg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With