Step by Step guide – Convert to Maven Project in Eclipse

Post moved to:

http://srinichekuri.com/2016/01/15/step-by-step-guide-convert-to-maven-project-in-eclipse/

**********************************************************************

This post is for step by step guide to convert a single project to Maven project in Eclipse. I recommend going through these links before you read any further.

Step 1: Maven Plugin for Eclipse

First you should make sure that you have Maven Plugin installed in your Eclipse. I am using Eclipse Mars for this demo and this version comes with Maven Plugin. If you are using Eclipse doesn’t have this built in feature then try to install a Maven Plugin. I recommend M2Eclipse Plugin.

Step 2: Convert Java/J2ee Project to Maven Project

Right click on Java Eclipse and select Configure -> Convert to Maven Project.

convert_to_Maven_Project_Eclipse

A popup up that will show build parameters that will be published in pom.xml will be shown.

convert_to_Maven_Project_Eclipse_1

Step 3: Add dependencies to pom.xml

Open pom.xml and Click on Dependencies tab.

Lets try to add log4j.jar as a dependency in pom.xml.

convert_to_Maven_Project_Eclipse_3

convert_to_Maven_Project_Eclipse_4

Step 4: Run Maven Build

Run Maven build by right clicking on pom.xml and selecting Run As -> Maven install.

convert_to_Maven_Project_Eclipse_5

Step 5: Verify Build

You will see that folder is created with naming convention <artifactId>-<version> in build folder. Also you will see that all dependencies are saved to build/<artifactId>-<version>/WEB-INF/lib folder. Also you will see all dependecies are placed in build path under Maven Dependencies.

convert_to_Maven_Project_Eclipse_6

 

convert_to_Maven_Project_Eclipse_7

Multiple dependencies can be added in similar fashion.

 

Advertisements

Step by Step guide to configure Eclipse and Apache Tomcat

This post has been moved to http://srinichekuri.com/2016/01/12/step-by-step-guide-to-configure-eclipse-and-apache-tomcat/

*********************************************************************

Eclipse is a very commonly used IDE by developers across the globe. Eclipse with Apache Tomcat server is a great combination for beginners and for experienced web developers.

This post will provide step-by-step guidance to set up Eclipse with Tomcat Server.

Note: Below screen shots are for windows 64-bit version. Please act accordingly for 32-bit versions.

Step-1: Download Java.

Click Here to download Java 7 SDK.

Java7_download

You will see that there are two folder created in your C:\Program files\Java. (In my case I already had Java 6 installed too).

Java7_download_2

Step-2: Download Apache Tomcat Server

Click Here to download Apache Tomcat Server 7.

Apache_Tomcat7_download

Once dowloaded, extract the server to D:\Software. You will see following structure after the extract is complete.

Apache_Tomcat7_download_1

Note: you can also choose to install from 32-bit/64-bit Windows Service Installer if you want to install it like a service.

Step-3: Configure Environment Variables

Configure following environment variables and restart your pc when done.

  • JAVA_HOME: “C:\Program Files\Java\jdk1.7.0_79”java_home_environment_variable
  • JRE_HOME: “C:\Program Files\Java\jre7”jre_home_environment_variable
  • CATALINA_HOME: “D:\Software\apache-tomcat-7.0.67”catalina_home_environment_variable

 

Step-4: Download Eclipse

Click Here to download Eclipse. For this guide, I am downloading Eclipse Mars. But you can download anything that is compatible with Java version you downloaded.

Eclipse_Mars_Download

Once downloaded extract contents to D:\Software.  You will see following structure after download is complete.

Eclipse_Mars_Download_1

 

Step 5: Setup Server Configuration in Eclipse

Open Eclipse and Open Server View (Window -> Show View -> Servers)

Right Click New -> Server

Eclipse_server_setup

Select Tomcat 7. You might have to Add Server runtime environment.

Eclipse_server_setup_1

(Dialog when clicked on ‘Add…’ in above screen shot)

Eclipse_server_setup_2

Click on Finish when Done.

Double click on Server to open deployment descriptor and make sure that you have default ports.

Eclipse_server_setup_3

Now start the server by clicking on start button and you will see that server has started successfully.

Eclipse_server_setup_4

Eclipse_server_setup_5

Hope this Set up process was helpful. Please use the comment section if you face any issues setting up and I will help  you as soon as I can.