Wednesday, September 11, 2013

Hello World With Maven in Eclipse IDE

We will develop Hello World app, without using Maven Console based commands,

Please follow the below steps.
1. Download Eclipse IDE for Java EE Developers, this contain all preconfigured Maven Plugin, you dont have to waste time in extra configurations.

2.  In Eclipse open the New Project Wizard by clicking File --> New --> Project. Under 'Maven' select 'Maven Project' and click 'Next'

3. On the next page of wizard, check 'Create a simple project' and click 'Next'

4. On the next Page of Wizard, Give a 'Group Id' and an 'Artifact Id' and click 'Finish'.

5.  Create a class with a main method in src/main/java. In this case I created

6. In the main method we will print out message and our project look like 

7. Now we have to deploy our project, our created pom.xml is not ready to deploy our application properly. Through the pom file we can instruct Maven about how to deploy our project, such as which class is the main class. We have to add following entries in pom.xml.

8. Remember, whenever you do manual changes in pom.xml you have to Run Maven->Update Project.

9. Now we will build project with Maven, If we right-click on the pom.xml file and select Run As menu, we will see a list of options as shown in the following figure.

If you select the Maven install option, Maven will compile and test our code and if all goes well it creates the JAR file in the target directory. The Maven clean option will empty the target directory and the Maven test will simply run the test cases.

10. Now run jar file and you will see

No comments: