3

In a project where I use the scala language, with sbt can launch directly from the terminal the command:

sbt run

Now I switched to use java with maven. If I try to run in the terminal:

mvn run 

the command does not work. The error is:

[ERROR] Unknown lifecycle phase "run" ...

There is an alternative way to do it? Thanks a lot.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
user3676015
  • 53
  • 1
  • 11
  • Take a look at this: http://stackoverflow.com/questions/1089285/maven-run-project – Aritra Sep 25 '14 at 17:37
  • So there is exec-maven-plugin.Ok, thank you! – user3676015 Sep 25 '14 at 17:49
  • 2
    You don't have to switch to maven when developing in Java. sbt can do the job very well. Just place your `.java` files under `src/main/java` and give `run` a go! You don't even have to have `build.sbt` in a project to use sbt provided the project follows the standard project structure with `src/main/{scala|java}`. – Jacek Laskowski Sep 25 '14 at 18:05
  • wow.. great! I thought that sbt ​​is used only with scala. this is very useful! thank you – user3676015 Sep 25 '14 at 18:12

1 Answers1

0

Use the maven exec plugin.

mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ...

You can configure the plugin in your pom.xml to set what the default main class and default arguments should be.

kag0
  • 5,624
  • 7
  • 34
  • 67