Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Windows

...

Guide

...

to

...

Installing

...

Wicket

...

on

...

Eclipse

...

with

...

Maven

Download & Install Maven

Maven is a project management tool. It does a million things, but I only know three of those things. We'll use Maven to get the Wicket Quickstart, convert it to an Eclipse project, and package our WARs. But first we need to get Maven.

1. Go to http://maven.apache

...

.org/download.html.

2. Click the "apache-maven-2.0.10-bin.zip"

...

link.

...

 Image Added

 3. Click the link at the top of the page.
Image Added

4. That will prompt you to download a file called apache-maven-2.0.10-bin.zip

...

.

...

Save

...

it

...

to

...

your

...

desktop.

...

5. Inside the zip file is a folder called apache-maven-2.0.10

...

.

...

Drag

...

that

...

folder

...

and

...

put

...

it

...

directly

...

onto

...

your

...

C:

...

drive--

...

C:\apache-maven-2.0.10

...

.

...

*IMPORTANT*---Maven

...

has

...

problems

...

if

...

its

...

path

...

has

...

any

...

spaces

...

in

...

it.

...

For

...

example,

...

don't

...

put

...

Maven under your "Program

...

Files"

...

folder,

...

since

...

there's

...

a

...

space

...

in

...

"Program

...

Files".

...

6. Add an environment variable called MAVEN_HOME

...

with

...

a

...

value

...

of

...

C:\apache-maven-2.0.10

...

.

...

You

...

can

...

learn

...

how

...

to

...

set

...

environment

...

variables

...

here:

...

http://www.chem.gla.ac.uk/~louis/software/faq/q1.html#winXP

...

7. Add Maven's

...

"bin"

...

directory

...

to

...

your

...

PATH

...

environment

...

variable.

...

In

...

this

...

case,

...

you

...

can

...

just

...

paste
; C:\apache-maven-2.0.10\bin

...


to

...

the

...

end

...

of

...

your

...

PATH.

...

Don't

...

forget

...

to

...

put

...

the

...

semicolon

...

in

...

front,

...

to

...

separate

...

it

...

from

...

anything

...

that's

...

already

...

in

...

your

...

PATH.

...

8. If you don't

...

have

...

a

...

JAVA_HOME

...

environment

...

variable,

...

then

...

create

...

one

...

of

...

those

...

too,

...

pointing

...

at

...

a

...

JDK

...

installation

...

on

...

your

...

computer.

...

9.  Now you have Maven ready to go. You can check that it's been installed correctly by opening a command prompt (Start -> Run... -> cmd) and typing in "mvn -version". That should display a couple lines of information about your Maven installation.

Download Eclipse

Eclipse is a great IDE for developing Java applications.

1. Go to http://www.eclipse.org/downloads/

...

.

2. Click the Eclipse IDE for Java Developers link.
Image Added

3. Click the big green download arrow.

Image Added
4. That will prompt you to download a file called eclipse-jee-ganymede-SR2-win32.zip

...

.

...

Save

...

it

...

to

...

your

...

desktop.

...

5. Inside the zip file is a folder called eclipse. Drag that folder and put it directly onto your C: drive---_C:\eclipse

...

_

...

.

6. That's

...

it.

...

Now

...

you

...

can

...

run

...

Eclipse

...

by

...

going

...

into

...

the

...

eclipse

...

folder

...

and

...

running

...

eclipse.exe.

...

Download

...

WTP

...

(optional)

...

WTP

...

is

...

an

...

Eclipse

...

plugin

...

that

...

provides

...

nice

...

web

...

editing

...

tools,

...

including

...

a

...

good

...

HTML

...

editor.

...

It's

...

not

...

necessary,

...

it's

...

nice

...

to

...

have.

...

If

...

you

...

don't

...

want

...

WTP,

...

skip

...

this

...

part.

...

You

...

can

...

always

...

come

...

back

...

and

...

do

...

it

...

later.

1.

...

Go

...

to

...

http://download.eclipse.org/webtools/downloads/

...

.

2. Click the 3.0.4

...

link.

Image Added

 
3. Then click the wtp link under *Web App Developers.*Image Added
4. Then click the big green arrow.

Image Added
 

5. That will prompt you to download a file called wtp-R-3.0.4-20090213193639.zip

...

.

...

Save

...

it

...

to

...

your

...

desktop.

...

6. Inside the zip file is a folder called eclipse. Drag that folder and put it directly onto your C: drive. A popup window will tell you that there's already a folder called eclipse there, and ask if you want to continue. Say yes. That will copy the contents of this eclipse folder into the eclipse folder that's already on your C: drive.

7. That's it. Now you will have access to the WTP tools when using Eclipse. 

Install M2Eclipse

M2Eclipse is an Eclipse plugin that allows you to run your Maven project from within Eclipse.

1. Open Eclipse.
2. Go to the Help menu and select Software Updates...
3. A pop-up window will open. Make sure the Available Software tab is selected at the top of the pop-up window.
4. Click the "Add Site..." button on the right. That will pop up another window.
5. Paste http://m2eclipse.sonatype.org/

...

sites/

...

m2e into

...

the

...

Location

...

bar.

...

Then

...

click

...

OK.

...


Image Added
6. This will add a line to the Available Software list titled Maven Integration for Eclipse Update Site
Image Added

7. Check the checkbox next to Maven Integration for Eclipse Update Site and click "Install...".

...


8. A window will pop-up

...

saying

...

that

...

the

...

items

...

you

...

selected

...

may

...

not

...

be

...

valid

...

yadda

...

yadda

...

yadda.

...

Click

...

"Yes".

...


Image Added

9. Uncheck the boxes next to Maven Integration for AJDT and Maven SCM handler for Subclipse.
Image Added

10. Click "Finish".

...

That's

...

it.

...

Now

...

you've

...

got

...

everything

...

ready

...

to

...

build

...

your

...

first

...

Wicket application.

Build Wicket Quickstart

We're

...

almost

...

there.

...

Everything

...

you've

...

done

...

so

...

far

...

will

...

never

...

need

...

to

...

be

...

done

...

again.

...

This

...

section

...

contains

...

all

...

the

...

directions

...

to

...

start

...

a

...

new

...

project.

...

Whenever

...

you

...

want

...

to

...

start

...

a

...

new

...

project,

...

you

...

can

...

come

...

back

...

to

...

these

...

steps.

...

The

...

Wicket

...

Quickstart

...

contains

...

all

...

of

...

the

...

files

...

and

...

libraries

...

necessary

...

to

...

make

...

a

...

Wicket

...

project.

...

It

...

lives

...

in

...

the

...

Maven

...

repository,

...

so

...

we'll

...

use

...

Maven

...

to

...

download

...

it

...

and

...

build

...

it,

...

and

...

then

...

we'll

...

import

...

it

...

into

...

Eclipse

...

for

...

you

...

to

...

play

...

with.

...

1. Create a folder called on wicket on your C: drive to contain your Wicket projects---

...

C:\wicket

...

.
2. Now open a browser and go to http://wicket.apache.org/quickstart.html

...

.
3. Under the "Creating

...

the

...

project"

...

section

...

of

...

the

...

page,

...

enter

...

a

...

GroupId

...

and

...

an

...

ArtifactId.

...

The

...

GroupId

...

can

...

be

...

any

...

string

...

that

...

reasonably

...

identifies

...

your

...

organization.

...

The

...

ArtifactId

...

will

...

be

...

the

...

name

...

of

...

your

...

project.

...

Leave

...

Version

...

at

...

1.3.5.

...

(You're

...

welcome

...

to

...

try

...

1.4,

...

but

...

I

...

haven't

...

had

...

much

...

luck

...

with

...

that.)

...

Image Added
4. Now open a command prompt (Start -> Run...

...

->

...

cmd)

...

and

...

navigate

...

to

...

_C:\wicket

...

_.
5.

...

Copy

...

the

...

text

...

inside

...

the

...

"Command

...

Line"

...

textbox

...

from

...

step

...

3

...

above

...

and

...

paste

...

it

...

into

...

your

...

command

...

prompt.

...

Hit

...

enter.

...

Then

...

wait

...

as

...

Maven

...

downloads

...

a

...

bunch

...

of

...

stuff.

...

Image Added
6. When that finishes,

...

you

...

will

...

see

...

that

...

a

...

new

...

folder

...

called

...

firstWicketProject

...

has

...

been

...

created

...

in

...

your

...

C:\wicket

...

_

...

folder.

...

From

...

your

...

command

...

prompt,

...

navigate

...

into

...

_firstWicketProject

...

.
7. Your command prompt should now be in C:\wicket\

...

firstWicketProject. From here,

...

type

...


mvn

...

eclipse:eclipse

...


and

...

hit

...

Enter.

...

Wait

...

while

...

Maven

...

download

...

more

...

stuff.

...


8. Now open Eclipse,

...

if

...

you

...

don't

...

already

...

have

...

it

...

open.

...

Go

...

to

...

the

...

File

...

menue

...

and

...

select

...

Import...

...

A

...

window

...

will

...

pop

...

up

...

with

...

several

...

folders.

...


9. Expand the top folder, named "General".

...

Select

...

the

...

"Existing

...

Projects

...

into

...

Workspace"

...

option

...

and

...

click

...

"Next"

...

.

Image Added
10. Click the "Browse..."

...

button

...

to

...

the

...

right

...

of

...

the

...

"Select

...

root

...

directory"

...

prompt

...

.

Image Added
11. Navigate to C:\wicket\firstWicketProject

...

and

...

click

...

"OK

...

".
12. The Projects area of the window will now show "firstWicketProject" with a checkbox checked next to it. Click Finish. 

Running the Application

Congratulations! You've installed the necessary software and built your first Wicket project. Now lets look at the project files and get it running.

  1. In the Package Explorer on the left hand side of the screen, you'll now see a folder called "firstWicketProject". If you expand that folder you'll lots of stuff. The important items are src/main/java, src/test/java, and src.
  2. src/main/java contains the project Java and HTML files. This is where you'll add new pages.
  3. src/test/java contains the embedded server. We'll come back here in a minute.
  4. src contains your web.xml file. You'll find it under src/main/webapp/WEB-INF

...

  1. .

...

  1. Use

...

  1. that

...

  1. to

...

  1. set

...

  1. up

...

  1. your

...

  1. project

...

  1. configuration.

...

  1. Now

...

  1. go

...

  1. back

...

  1. to

...

  1. src/test/java

...

  1. .

...

  1. Inside

...

  1. you'll

...

  1. see

...

  1. a

...

  1. package

...

  1. that

...

  1. has

...

  1. the

...

  1. same

...

  1. name

...

  1. as

...

  1. the

...

  1. GroupId

...

  1. you

...

  1. entered

...

  1. on

...

  1. the

...

  1. Quickstart

...

  1. website.

...

  1. Expand

...

  1. the

...

  1. package

...

  1. inside

...

  1. src/test/java

...

  1. and

...

  1. you'll

...

  1. see

...

  1. a

...

  1. Java

...

  1. file

...

  1. called

...

  1. Start.java.

...

  1. Right-click

...

  1. Start.java

...

  1. and

...

  1. go

...

  1. down

...

  1. to

...

  1. "Debug

...

  1. as..."

...

  1. and

...

  1. select

...

  1. "Java

...

  1. Application".

...

  1. You'll

...

  1. see

...

  1. the

...

  1. server

...

  1. starting

...

  1. up

...

  1. inside

...

  1. the

...

  1. console

...

  1. at

...

  1. the

...

  1. bottom

...

  1. of

...

  1. the

...

  1. screen.

...

  1. To

...

  1. test

...

  1. to

...

  1. see

...

  1. if

...

  1. everything

...

  1. is

...

  1. working,

...

  1. open

...

  1. a

...

  1. browser

...

  1. and

...

  1. go

...

  1. to

...

  1. http://localhost:8080

...

  1. .

...

  1. You

...

  1. should

...

  1. see

...

  1. a

...

  1. message

...

  1. telling

...

  1. you

...

  1. and

...

  1. Wicket

...

  1. is

...

  1. running.

...

  1. To

...

  1. stop

...

  1. the

...

  1. server,

...

  1. click

...

  1. the

...

  1. red

...

  1. square

...

  1. at

...

  1. the

...

  1. top

...

  1. right

...

  1. of

...

  1. the

...

  1. console

...

  1. in

...

  1. Eclipse.

...

  1. You

...

  1. may

...

  1. need

...

  1. to

...

  1. stop

...

  1. and

...

  1. start

...

  1. the server after you make programming changes in order for the changes to take effect. 

    Bonus Section

That's just about everything. Now you're ready to go into your src/main/java and start building your application. However, there are two more changes I suggest you make.

  1. Open the pom.xml file in the project root directory and scroll toward the bottom, where you'll find:
    Code Block
    
    <plugin>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-eclipse-plugin</artifactId>
    	<configuration>
    		<downloadSources>true</downloadSources>
    	</configuration>
    </plugin>		
    
    and add the line
    Code Block
    
    <version>2.5.1</version>
    
    right after
    Code Block
    
    <artifactId>maven-eclipse-plugin</artifactId>
    
  2. Go back to src/test/java and open the Start.java file into the Eclipse editor.
  3. Delete the entire contents of the file and paste in the following instead. I find this change helps the embedded server to pick up your code changes without needing to be restarted.
Code Block

package edu.chemeketa;

import  server after you make programming changes in order for      the changes to take effect. 
h2. Bonus Section

That's just about everything. Now you're ready to go into your _src/main/java_ and start building your application. However, there's one more change I suggest you make.
# Go back to _src/test/java_ and open the      Start.java file into the Eclipse editor.
# Delete the entire contents      of the file and paste in the following instead. I find this change helps      the embedded server to pick up your code changes without needing to be      restarted.
\\

| | package     edu.chemeketa;\\
 \\
import     java.lang.management.ManagementFactory;\\
 \\

import     javax.management.MBeanServer;\\
 \\
import     org.mortbay.jetty.Server;\\
import     org.mortbay.jetty.nio.SelectChannelConnector;\\
import     org.mortbay.jetty.webapp.WebAppContext;\\
import     org.mortbay.management.MBeanContainer;\\
 \\
/*\*\\
&nbsp;\
 * Seperate startup class for people that     want to run the examples\\
&nbsp;\
 * directly.\\
&nbsp;\
 */\\
public class     Start {\\

 \\
&nbsp; /*\*\\
&nbsp;&nbsp; \
   * Main function, starts the jetty server.
    server.\\
&nbsp;&nbsp; \* \\
&nbsp;&nbsp; \*
   * @param args\\
&nbsp;&nbsp; \
   */\\
&nbsp;  public static void main(String\[\] args)     throws Exception {\\

 \\
&nbsp;&nbsp;&nbsp;    Server server = new Server();\\
&nbsp;&nbsp;&nbsp;
    SelectChannelConnector connector = new     SelectChannelConnector();\\
&nbsp;&nbsp;&nbsp;
    connector.setPort(8080);\\
&nbsp;&nbsp;&nbsp;
    server.addConnector(connector);\\
 \\
&nbsp;&nbsp;&nbsp;connector);

    WebAppContext web = new     WebAppContext();\\
&nbsp;&nbsp;&nbsp;
    web.setContextPath("/");\\
&nbsp;&nbsp;&nbsp;
    web.setWar("src/main/webapp");\\
&nbsp;&nbsp;&nbsp;
    server.addHandler(web);\\

 \\
&nbsp;&nbsp;&nbsp;   MBeanServer mBeanServer = ManagementFactory
       ManagementFactory\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .getPlatformMBeanServer();\\
&nbsp;&nbsp;&nbsp;
    MBeanContainer mBeanContainer = new     MBeanContainer(mBeanServer);\\
&nbsp;&nbsp;&nbsp;
    server.getContainer().addEventListener(mBeanContainer);\\
&nbsp;&nbsp;&nbsp;(mBeanContainer);
    mBeanContainer.start();\\

 \\
&nbsp;&nbsp;&nbsp;   try {\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      System.out.println(">>>     STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      server.start();\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      while (System.in.available() == 0) {\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        Thread.sleep(5000);\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;
      }
      server.stop();\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      server.join();\\
&nbsp;&nbsp;&nbsp;
    } catch (Exception e) {\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e) {
      e.printStackTrace();\\
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      System.exit(100);\\
&nbsp;&nbsp;&nbsp; }\\
&nbsp; }\\
}\\ | | 
    }
  }
}