I am trying to run a simple Java project. I had created a project using the 'Maven Project' type. I have one main class called 'TestMain'. When I tried to run the project using right click -> run, there was no menu to run the application as 'Run As Java Application'. I am wondering where that option has gone.
Can anyone please help me to run the Java application?
Your Maven project doesn't seem to be configured as a Eclipse Java project, that is the Java nature is missing (the little 'J' in the project icon).
To enable this, the <packaging>
element in your pom.xml should be jar
(or similar).
Then, right-click the project and select Maven > Update Project Configuration
For this to work, you need to have m2eclipse installed. But since you had the _ New ... > New Maven Project_ wizard, I assume you have m2eclipse installed.
(Alt + Shift + X) , then M
to Run Maven Build. You will need to specify the Maven goals you want on Run -> Run Configurations
Source: Stackoverflow.com