Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

...

  1. Click

...

  1. the

...

  1. link

...

  1. at

...

  1. the

...

  1. top

...

  1. of

...

  1. the

...

  1. page.

...

  1. That

...

  1. will

...

  1. prompt

...

  1. you

...

  1. to

...

  1. download

...

  1. a

...

  1. file

...

  1. called

...

  1. apache-maven-2.0.10-bin.zip

...

  1. .

...

  1. Save

...

  1. it

...

  1. to

...

  1. your

...

  1. desktop.

...

  1. Inside

...

  1. the

...

  1. zip

...

  1. file

...

  1. is

...

  1. a

...

  1. folder

...

  1. called

...

  1. apache-maven-2.0.10

...

  1. . Drag that folder and put it directly onto your C: drive--C:\apache-maven-2.0.10

...

  1. _

...

  1. .

...

  1. _*IMPORTANT

...

  1. *-

...

  1. -

...

  1. Maven

...

  1. has

...

  1. problems

...

  1. if

...

  1. its

...

  1. path

...

  1. has

...

  1. any

...

  1. spaces

...

  1. in

...

  1. it.

...

  1. For

...

  1. example,

...

  1. don't

...

  1. put

...

  1. Maven

...

  1. under

...

  1. your

...

  1. "Program

...

  1. Files"

...

  1. folder,

...

  1. since

...

  1. there's

...

  1. a

...

  1. space

...

  1. in

...

  1. "Program

...

  1. Files".

...

  1. Add

...

  1. an

...

  1. environment

...

  1. variable

...

  1. called

...

  1. MAVEN_HOME

...

  1. with

...

  1. a

...

  1. value

...

  1. of

...

  1. C:\apache-maven-2.0.10

...

  1. .

...

  1. You

...

  1. can

...

  1. learn

...

  1. how

...

  1. to

...

  1. set

...

  1. environment

...

  1. variables

...

  1. here:

...

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

...

  1. Add

...

  1. Maven's

...

  1. "bin"

...

  1. directory

...

  1. to

...

  1. your

...

  1. PATH

...

  1. environment

...

  1. variable.

...

  1. In

...

  1. this

...

  1. case,

...

  1. you

...

  1. can

...

  1. just

...

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

...


  1. to

...

  1. the

...

  1. end

...

  1. of

...

  1. your

...

  1. PATH.

...

  1. Don't

...

  1. forget

...

  1. to

...

  1. put

...

  1. the

...

  1. semicolon

...

  1. in

...

  1. front,

...

  1. to

...

  1. separate

...

  1. it

...

  1. from

...

  1. anything

...

  1. that's

...

  1. already

...

  1. in

...

  1. your

...

  1. PATH.

...

  1. If

...

  1. you

...

  1. don't

...

  1. have

...

  1. a

...

  1. JAVA_HOME

...

  1. environment

...

  1. variable,

...

  1. then

...

  1. create

...

  1. one

...

  1. of

...

  1. those

...

  1. too,

...

  1. pointing

...

  1. at

...

  1. a

...

  1. JDK

...

  1. installation

...

  1. on

...

  1. your

...

  1. computer.

...

  1. Now

...

  1. you

...

  1. have

...

  1. Maven

...

  1. ready

...

  1. to

...

  1. go.

...

  1. You

...

  1. can

...

  1. check

...

  1. that

...

  1. it's

...

  1. been

...

  1. installed

...

  1. correctly

...

  1. by

...

  1. opening

...

  1. a

...

  1. command

...

  1. prompt

...

  1. (Start

...

  1. ->

...

  1. Run...

...

  1. ->

...

  1. cmd)

...

  1. and

...

  1. typing

...

  1. in

...

  1. "mvn

...

  1. -version".

...

  1. That

...

  1. should

...

  1. display

...

  1. a

...

  1. couple

...

  1. lines

...

  1. of

...

  1. information

...

  1. about

...

  1. your

...

  1. Maven

...

  1. installation.

...

  1.  

    Download Eclipse

Eclipse is a great IDE for developing Java applications.

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

...

  1. .

...

  1. Click

...

  1. the

...

  1. Eclipse

...

  1. IDE

...

  1. for

...

  1. Java

...

  1. Developers

...

  1. link.

...

  1. Click

...

  1. the

...

  1. big

...

  1. green

...

  1. download

...

  1. arrow.

...

  1. That

...

  1. will

...

  1. prompt

...

  1. you

...

  1. to

...

  1. download

...

  1. a

...

  1. file

...

  1. called

...

  1. eclipse-jee-ganymede-SR2-win32.zip

...

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

...

  1. _

...

  1. .

...

  1. That's

...

  1. it.

...

  1. Now

...

  1. 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

...

  1. to

...

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

...

  1. .

...

  1. Click

...

  1. the

...

  1. 3.0.4

...

  1. link:

...

  1. Then

...

  1. click

...

  1. the

...

  1. wtp

...

  1. link

...

  1. under

...

  1. Web

...

  1. App

...

  1. Developers

...

  1. :

...

  1. The

...

  1. click

...

  1. the

...

  1. big

...

  1. green

...

  1. arrow:

...

  1. That

...

  1. will

...

  1. prompt

...

  1. you

...

  1. to

...

  1. download

...

  1. a

...

  1. file

...

  1. called

...

  1. wtp-R-3.0.4-20090213193639.zip

...

  1. .

...

  1. Save

...

  1. it

...

  1. to

...

  1. your

...

  1. desktop.

...

  1. Inside

...

  1. the

...

  1. zip

...

  1. file

...

  1. is

...

  1. a

...

  1. folder

...

  1. called

...

  1. eclipse

...

  1. .

...

  1. Drag

...

  1. that

...

  1. folder

...

  1. and

...

  1. put

...

  1. it

...

  1. directly

...

  1. onto

...

  1. your

...

  1. C:

...

  1. drive.

...

  1. A

...

  1. popup

...

  1. window

...

  1. will

...

  1. tell

...

  1. you

...

  1. that

...

  1. there's

...

  1. already

...

  1. a

...

  1. folder

...

  1. called

...

  1. eclipse

...

  1. there,

...

  1. and

...

  1. ask

...

  1. if

...

  1. you

...

  1. want

...

  1. to

...

  1. continue.

...

  1. Say

...

  1. yes.

...

  1. That

...

  1. will

...

  1. copy

...

  1. the

...

  1. contents

...

  1. of

...

  1. this

...

  1. eclipse

...

  1. folder

...

  1. into

...

  1. the

...

  1. eclipse

...

  1. folder

...

  1. that's

...

  1. already

...

  1. on

...

  1. your

...

  1. C:

...

  1. drive.

...

  1. That's

...

  1. it.

...

  1. Now

...

  1. you

...

  1. will

...

  1. have

...

  1. access

...

  1. to

...

  1. the

...

  1. WTP

...

  1. tools

...

  1. when

...

  1. using

...

  1. Eclipse.

...

  1.  

    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/update/_

...

  1. into

...

  1. the

...

  1. Location

...

  1. bar.

...

  1. Then

...

  1. click

...

  1. OK.

...

  1. This

...

  1. will

...

  1. add

...

  1. a

...

  1. line

...

  1. to

...

  1. the

...

  1. Available

...

  1. Software

...

  1. list titled Maven Integration for Eclipse Update Site
  2. Check the checkbox next to Maven Integration for Eclipse Update Site and click "Install...".

...

  1. A

...

  1. window

...

  1. will

...

  1. pop-up

...

  1. saying

...

  1. that

...

  1. the

...

  1. items

...

  1. you

...

  1. selected

...

  1. may

...

  1. not

...

  1. be

...

  1. valid

...

  1. yadda

...

  1. yadda

...

  1. yadda.

...

  1. Click

...

  1. "Yes".

...

  1. Uncheck

...

  1. the

...

  1. boxes

...

  1. next

...

  1. to

...

  1. Maven

...

  1. Integration

...

  1. for

...

  1. AJDT

...

  1. and

...

  1. Maven

...

  1. SCM

...

  1. handler

...

  1. for

...

  1. Subclipse

...

  1. .

...

  1. Click

...

  1. "Finish".

...

  1. That's

...

  1. it.

...

  1. Now

...

  1. you've

...

  1. got

...

  1. everything

...

  1. ready

...

  1. to

...

  1. build

...

  1. your

...

  1. first

...

  1. Wicket

...

  1. 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

...

  1. a

...

  1. folder

...

  1. called

...

  1. on

...

  1. wicket

...

  1. on

...

  1. your

...

  1. C:

...

  1. drive

...

  1. to

...

  1. contain

...

  1. your

...

  1. Wicket

...

  1. projects---

...

  1. C:\wicket

...

  1. .

...

  1. Now

...

  1. open

...

  1. a

...

  1. browser

...

  1. and

...

  1. go

...

  1. to

...

  1. http://wicket.apache.org/quickstart.html

...

  1. .
    # 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.

...

  1. (You're

...

  1. welcome

...

  1. to

...

  1. try

...

  1. 1.4,

...

  1. but

...

  1. I

...

  1. haven't

...

  1. had

...

  1. much

...

  1. luck

...

  1. with

...

  1. that.)

...

  1. Now

...

  1. open

...

  1. a

...

  1. command

...

  1. prompt

...

  1. (Start

...

  1. ->

...

  1. Run...

...

  1. ->

...

  1. cmd)

...

  1. and

...

  1. navigate

...

  1. to

...

  1. _C:\wicket_.

...

  1. Copy

...

  1. the

...

  1. text

...

  1. inside

...

  1. the

...

  1. "Command

...

  1. Line"

...

  1. textbox

...

  1. from

...

  1. step

...

  1. 3

...

  1. above

...

  1. and

...

  1. paste

...

  1. it

...

  1. into

...

  1. your

...

  1. command

...

  1. prompt.

...

  1. Hit

...

  1. enter.

...

  1. Then

...

  1. wait

...

  1. as

...

  1. Maven

...

  1. downloads

...

  1. a

...

  1. bunch

...

  1. of

...

  1. stuff.

...

  1. When

...

  1. that

...

  1. finishes,

...

  1. you

...

  1. will

...

  1. see

...

  1. that

...

  1. a

...

  1. new

...

  1. folder

...

  1. called

...

  1. firstWicketProject

...

  1. has

...

  1. been

...

  1. created

...

  1. in

...

  1. your

...

  1. C:\wicket

...

  1. _

...

  1. folder.

...

  1. From

...

  1. your

...

  1. command

...

  1. prompt,

...

  1. navigate

...

  1. into

...

  1. _firstWicketProject

...

  1. .

...

  1. Your

...

  1. command

...

  1. prompt

...

  1. should

...

  1. now

...

  1. be

...

  1. in

...

  1. C:\wicket\firstWicketProject

...

  1. .

...

  1. From

...

  1. here,

...

  1. type

...


  1. mvn

...

  1. eclipse:eclipse

...


  1. and

...

  1. hit

...

  1. Enter.

...

  1. Wait

...

  1. while

...

  1. Maven

...

  1. download

...

  1. more

...

  1. stuff.

...

  1. Now

...

  1. open

...

  1. Eclipse,

...

  1. if

...

  1. you

...

  1. don't

...

  1. already

...

  1. have

...

  1. it

...

  1. open.

...

  1. Go

...

  1. to

...

  1. the

...

  1. File

...

  1. menue

...

  1. and

...

  1. select

...

  1. Import...

...

  1. A

...

  1. window

...

  1. will

...

  1. pop

...

  1. up

...

  1. with

...

  1. several

...

  1. folders.

...

  1. Expand

...

  1. the

...

  1. top

...

  1. folder,

...

  1. named

...

  1. "General".

...

  1. Select

...

  1. the

...

  1. "Existing

...

  1. Projects

...

  1. into

...

  1. Workspace"

...

  1. option

...

  1. and

...

  1. click

...

  1. "Next".

...

  1. Click

...

  1. the

...

  1. "Browse..."

...

  1. button

...

  1. to

...

  1. the

...

  1. right

...

  1. of

...

  1. the

...

  1. "Select

...

  1. root

...

  1. directory"

...

  1. prompt.

...

  1. Navigate

...

  1. to

...

  1. C:\wicket\firstWicketProject

...

  1. and

...

  1. click

...

  1. "OK".

...

  1. The

...

  1. Projects

...

  1. area

...

  1. of

...

  1. the

...

  1. window

...

  1. will

...

  1. now

...

  1. show

...

  1. "firstWicketProject"

...

  1. with

...

  1. a

...

  1. checkbox

...

  1. checked

...

  1. next

...

  1. to

...

  1. it.

...

  1. Click

...

  1. Finish.

...

  1.  

    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

...

  1. the

...

  1. Package

...

  1. Explorer

...

  1. on

...

  1. the

...

  1. left

...

  1. hand

...

  1. side

...

  1. of

...

  1. the

...

  1. screen,

...

  1. you'll

...

  1. now

...

  1. see

...

  1. a

...

  1. folder

...

  1. called

...

  1. "firstWicketProject".

...

  1. If

...

  1. you

...

  1. expand

...

  1. that

...

  1. folder

...

  1. you'll

...

  1. lots

...

  1. of

...

  1. stuff.

...

  1. The important items are src/main/java

...

  1. ,

...

  1. src/test/java

...

  1. ,

...

  1. and

...

  1. src

...

  1. .

...

  1. src/main/java

...

  1. contains

...

  1. the

...

  1. project

...

  1. Java

...

  1. and

...

  1. HTML

...

  1. files.

...

  1. This

...

  1. is

...

  1. where

...

  1. you'll

...

  1. add

...

  1. new

...

  1. pages.

...

  1. src/test/java

...

  1. contains

...

  1. the

...

  1. embedded

...

  1. server.

...

  1. We'll

...

  1. come

...

  1. back

...

  1. here

...

  1. in

...

  1. a

...

  1. minute.

...

  1. src contains your web.xml

...

  1. file.

...

  1. You'll

...

  1. find

...

  1. it

...

  1. under

...

  1. 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

...

  1. server

...

  1. after

...

  1. you

...

  1. make

...

  1. programming

...

  1. changes

...

  1. in

...

  1. order

...

  1. for

...

  1. the

...

  1. changes

...

  1. to

...

  1. 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's

...

one

...

more

...

change

...

I

...

suggest

...

you

...

make.

...

  1. Go

...

  1. back

...

  1. to

...

  1. src/test/java

...

  1. and

...

  1. open

...

  1. the

...

  1. Start.java

...

  1. file

...

  1. into

...

  1. the

...

  1. Eclipse

...

  1. editor.

...

  1. Delete

...

  1. the

...

  1. entire

...

  1. contents

...

  1. of

...

  1. the

...

  1. file

...

  1. and

...

  1. paste

...

  1. in

...

  1. the

...

  1. following

...

  1. instead.

...

  1. I

...

  1. find

...

  1. this

...

  1. change

...

  1. helps

...

  1. the

...

  1. embedded

...

  1. server

...

  1. to

...

  1. pick

...

  1. up

...

  1. your

...

  1. code

...

  1. changes

...

  1. without

...

  1. needing

...

  1. to

...

  1. be

...

  1. restarted.
Code Block



{{
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;

/**
 * Seperate startup class for people that want to run the examples
 * directly.
 */
public class Start {

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

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

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

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

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