You need to have Java 1.6 or higher version, eclipse IDE for J2EE developers , Maven 2.2.1 or higher version and Apache Tomcat 6.0 or higher version installed on your system to follow this tutorial.
Step1 : Integrate m2eclipse plugin into eclipse
Get the m2eclipse url from the following site (figure 1)
http://eclipse.org/m2e/download/
Figure 1
Open up your eclipse -> Help -> Install New Software -> Click Add
Put m2eclipse under Name field and Copy the url to Location box (figure 2)
Figure 2
Click Ok and it will list m2e under plugins to be installed (figure3).
Figure 3
Select it then click next -> next -> finish.
wait till it is finished downloading required dependencies in to your eclipse instance.
When it is done restart your eclipse IDE.
Now you have completed installing m2e on your eclipse instance...!
Step2 : Create New Maven Project
Open up your eclipse instance.
File -> New -> Other -> Expand Maven -> Select Maven Project -> Click Next ->
Select Workspace Location (figure 4) Click Next
Step 3: Add maven-compiler-plugin and maven-eclipse plugin in to pom.xml
File -> New -> Other -> Expand Maven -> Select Maven Project -> Click Next ->
Select Workspace Location (figure 4) Click Next
Figure 4
Select maven-archetype-webapp (figure 5) Click Next
Figure 5
Click Finish
Set GroupID, ArtifactID and Package name as given below (Figure 6), Leave Version to the default value given.
Figure 6
Step 3: Add maven-compiler-plugin and maven-eclipse plugin in to pom.xml
Figure 7
Add following configuration under <build></build> section of the project pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven. plugins</groupId>
<artifactId>maven-eclipse- plugin</artifactId>
<configuration>
<wtpversion>1.5</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven. plugins</groupId>
<artifactId>maven-compiler- plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
After adding above configuration it will look like as follows... ( figure 8 )
Figure 8
Following Guide is for Windows Users...
Windows7 ships with a command prompt named as Windows PowerShell in which you get the freedom to use linux shell commands.
use that command prompt change to the directory where your project is located using
cd
command.
then follow the Linux and Mac Users guide where you can use same commands on Windows power shell and even in windows command prompt.
Following Guide is for Linux, Mac Users...
Open up a Terminal and change to your project directory.
Type $ mvn clean install
Then Type $ mvn eclipse:eclipse
This will download required libraries in to maven repository.
Go back to eclipse and refresh your project
Then your project structure will be changed as shown below ( figure 9 )
Figure 9
Step 6 : Add source directory to your project
right click on main directory and create new folder named java as shown below ( figure 10 )
Figure 10
Get back to your Terminal (for mac and linux users) or command prompt (for windows users) and type
$ mvn clean install
and then
$ mvn eclipse:eclipse
as earlier
this will change the project structure to the following look ( figure 11 )
Figure 11
Step 7 : Run your project
Right click on your project
Select Run As option
Select Run on Server ( figure 12 )
Figure 12
Select Apache Tomcat Server version ( i user Tomcat 7 since i have downloaded it, you can use 6 if you have downloaded it) click finish.
This will take you to the HelloWorld Message on eclipse browser ( figure 13 )
Figure 13
Nice tutorial, but I can't run on the server - I don't get that option. It gives me Java Applet, Java Application - but not not on server. Any suggestions?
ReplyDeleteThanks
Dave
Hi Dave, Thank you for the interest. do you have tomcat server running on your computer
ReplyDeleteHi ....gud one but i am working on windows xp os ...can u pls explain me how to run mvn eclipse command on windows
ReplyDeleteThanx in advance
Hi,In modern website design and development, jQuery is the most popular JavaScript library in use for Web Design Cochin. jQuery extends the possibilities of the website and simplifies the entire website development process.Thanks..........
ReplyDelete