Run Netbeans maven project from command-line?

点点圈 提交于 2019-12-05 22:37:28

问题


I've got a Maven project that runs perfectly inside Netbeans. How can I execute the application from the command-line (without Netbeans)?


回答1:


There's a plugin for that: http://www.mojohaus.org/exec-maven-plugin/

$ mvn exec:java -Dexec.mainClass="com.mycompany.App"

Assuming com.mycompany.App is you main class.




回答2:


Using the Maven Exec Plugin and its exec:java goal as suggested is a first option. And the command suggested is correct, you have to specify -Dexec.mainClass=VALUE on the command line.

mvn exec:java -Dexec.mainClass=com.acme.Hello

Regarding your "classpath problem", well, you didn't describe it very clearly. What is your problem? What are your dependencies exactly? Just in case, there is a classpathScope parameter allowing to define the scope of the classpath passed to the plugin. E.g.:

mvn exec:java -Dexec.classpathScope=compile -Dexec.mainClass=com.acme.Hello

As an alternative to the above plugin, there is MOP. What is MOP?

What is MOP?

MOP is a small utility for executing Java programs which are stored as artifacts like jars or bundles in a Maven repository.

MOP automatically deals with the following for you

  • transitive dependencies
  • downloading artifacts from remote repositories and caching them locally
  • setting up your classpath


来源:https://stackoverflow.com/questions/3689020/run-netbeans-maven-project-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!