= Creating your own application
:Author: Pete Muir

[[Archetype-]]

What we didn't tell you about the kitchensink quickstart is that it is generated from a Maven archetype. Using this archetype offers you the perfect opportunity to generate your own project. 

You can create a project from the archetype using Red Hat JBoss Developer Studio, or Eclipse with JBoss Tools. First, open up _JBoss Central_, if it isn't already open. Hit _Cmd-3_ (Mac) or _Ctrl-3_ (Windows, Linux) and type _JBoss Central_:

image:gfx/Eclipse_JBoss_Central_1.png[]

You will now be shown _JBoss Central_, an excellent place to find about all things JBoss!

image:gfx/Eclipse_JBoss_Central_2.png[]

To create a new project, based on the kitchensink quickstart, click on _Create Projects | Java EE Web Project_:

image:gfx/Eclipse_JavaEEWebProject_1.png[]

Red Hat JBoss Developer Studio will then check that you have the necessary pre-requisites to create the project. If you are using JBoss Developer Studio, then you should, otherwise, JBoss Tools will help you install the necessary pre-requisites. See link:http://jboss.org/tools[JBoss Tools] for more information.

Hit _Next >_. On the next screen you can enter a project name, package for sample code, and finally select a target runtime:

image:gfx/Eclipse_JavaEEWebProject_2.png[]

Finally, hit _Finish_. You'll be presented with the _New Project Example_ dialog, in which you can simply hit _Finish_:

image:gfx/Eclipse_JavaEEWebProject_3.png[]

You should now have a brand new project:

image:gfx/Eclipse_JavaEEWebProject_4.png[]

Enjoy!


To use the archetype to generate a new project, you should run:

    mvn archetype:generate \
        -DarchetypeArtifactId=jboss-javaee7-webapp-archetype \
        -DarchetypeGroupId=org.jboss.spec.archetypes \
        -DarchetypeVersion=7.1.1.CR2 \

Maven will download the archetype and it's dependencies, and ask you some questions:

------------------------------------------------------------------------
$ > mvn archetype:generate \
        -DarchetypeArtifactId=jboss-javaee7-webapp-archetype \
        -DarchetypeGroupId=org.jboss.spec.archetypes \
        -DarchetypeVersion=7.1.1.CR2
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]

.........

Define value for property 'groupId': : com.acme.corp                 <1>
Define value for property 'artifactId': : acme-sales                 <2>
Define value for property 'version':  1.0-SNAPSHOT: :                <3>
Define value for property 'package':  com.acme.corp: :               <4>
[INFO] Using property: name = Java EE webapp project               <5>
Confirm properties configuration:
groupId: com.acme.corp
artifactId: acme-sales
version: 1.0-SNAPSHOT
package: com.acme.corp
name: Java EE webapp project
 Y: :
[WARNING] CP Don't override file /Users/pmuir/tmp/acme-sales/.settings/org.eclipse.jdt.apt.core.prefs
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.774s
[INFO] Finished at: Mon Jun 06 18:53:38 BST 2011
[INFO] Final Memory: 7M/125M
[INFO] ------------------------------------------------------------------------
$ >
------------------------------------------------------------------------
<1> Enter the groupId you wish to use
<2> Enter the artifactId you wish to use
<3> Enter the version you wish to use, or just hit Enter if you wish to accept the default 1.0-SNAPSHOT
<4> Enter the java package you wish to use, or just hit Enter if you wish to accept the default (which is copied from groupId ).
<5> Finally, if you are happy with your choices, hit Enter and Maven will generate the project for you.

And that's it, you now have a brand new project with the same functionality as `kitchensink`, but customized with your details.

[IMPORTANT]
========================================================================
The archetype contains some sample code to get you started. If you
would prefer a blank canvas, with only a project skeleton, then use
`jboss-javaee7-webapp-blank-archetype` as your archetype id.
========================================================================

[IMPORTANT]
.Prefer Enterprise Applications (EARs)?
========================================================================
The archetype generates a WAR project. With Java EE, you can include 
EJBs in your WAR, meaning you won't need an EAR until you need to divide
your code into modules. If you would like to create an EAR based project
then use `jboss-javaee7-webapp-ear-archetype`
as your archetype id (or if you want a blank EAR, then
`jboss-javaee7-webapp-ear-blank-archetype`).
========================================================================


