It’s pretty straight forward to run Maven based projects in NetBeans IDE. For some projects that involve console related capabilities, you have to run it from OS console. One example is projects that use the JANSI APIs for colorful console output (see my last post for a sample). If you run the code within IDE, you won’t see the colors as would in a console.
While you can run the compiled code from console like any other Java applications, I found it’s not easy to get all the jars defined in the pom.xml as dependencies. There got to be an easier way that run the code from command line.
Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.
After a bit search, I found the exec-maven-plugin which is included in the Netbeans IDE if you download the all in one edition. Here is the command I used:
c:\Users\steve\git\TestApp>"c:\Program Files\NetBeans 7.3.1\java\maven\bin\mvn" exec:java -Dexec.mainClass="org.doublecloud.ShowColorText"
Note that you should first get into the directory with the pom.xml file of your project so that the plugin can get hold of the pom.xml for its dependent jar files. Also, the mainClass is case sensitive and should be typed exactly as shown above.
Although I got the problem while working with Netbeans, it’s not really much related to Netbeans. The solution can be used with any Maven project with any other IDEs.