Thursday, April 26, 2012

First Maven Project



Session1: First Maven Project

First session of Java crash course was conducted on last Saturday by yarl IT hub community.Jeyakumaran gave an introduction to web programming and Gayathiri gave an introduction to create the maven project.

Maven:
          Maven is open source build and project management tool. Purposes of maven:
·        Make the build process easy.
·        Provide a uniiform build system.
·        Provide quality project information.
·        Provide guidelines for ‘best practises’ in development.
·        Allows transparent migration to new features.

To create first project we followed the following steps :
Preprocesses :
1.     Install java jdk-7U3 and set the path
2.     Install NetBeans 7.1.1 with any server
3.     Install maven and set the path
4.  Add maven plugin to netbeans(peek-into-github)  
     (download instructions )
Steps :
  • Execute the command "mvn --version" in command prompt to check that whether the maven  is  installed correctly. 
  • Execute the command “mvn clean install”. This command tells the maven  to build all the modules and to install it in the local repository. The local repository is created in your home directory or alternative location that you created it,and is the location that all downloaded binaries and the project you built are stored. In order to create the maven project , execute the following command line:
                        "mvn archetype:generate
                    -DarchetypeArtifactId=mavenarchetype-webapp
                    -DgroupId=org.yarlithub.yschool
                    -DartifactId=yschool".                                                                                 Here “archetype” is general skeleton structure or template of a project. “groupId”  indicates the unique identifiers of the organisation or group that created the project. To the field “DartifactId”, we can give the name of our project.
    After the execution of this command a directory named “yschool” has been created for the new project and this directory contains a file named pom.xml which contains the Project Object Model for this project.The POM contains every important piece of information about your project. 
  • Navigate the path to the created folder and compile the project by using the command mvn compile. It will create a folder, target with compiled class.The first time you executed a command maven will need to download all the plugins and related dependancies it needs to fullfill the command.  
  •  Add the plug-in in “pom” file and run the project using the code mvn install jetty:run”. Jetty server will be started.
  • Now go to the browser and type “http://localhost:8080/<project-name> Ex:
    http://localhost:8080/yschool . It will display the output.
  • We can edit the coding in index.jsp file which is in    “E:\YSchool\yschool\src\main\webapp”

1 comment:

  1. Hi Keerthika,

    Good job. Can you explain why do we need maven archetypes? What is the use of it? What if we don't have that feature? Try to write a blog on it.

    Cheers,
    JK

    ReplyDelete