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.
3. Click the link at the top of the page.
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
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.
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.
3. Click the big green download arrow.
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.
2. Click the 3.0.4 link.
3. Then click the wtp link under *Web App Developers.*
4. Then click the big green arrow.
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.
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.
6. This will add a line to the Available Software list titled Maven Integration for Eclipse Update Site
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".
9. Uncheck the boxes next to Maven Integration for AJDT and Maven SCM handler for Subclipse.
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.)
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.
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
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".
10. Click the "Browse..." button to the right of the "Select root directory" prompt.
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.
- 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.
- src/main/java contains the project Java and HTML files. This is where you'll add new pages.
- src/test/java contains the embedded server. We'll come back here in a minute.
- src contains your web.xml file. You'll find it under src/main/webapp/WEB-INF. Use that to set up your project configuration.
- Now go back to src/test/java. Inside you'll see a package that has the same name as the GroupId you entered on the Quickstart website.
- Expand the package inside src/test/java and you'll see a Java file called Start.java. Right-click Start.java and go down to "Debug as..." and select "Java Application". You'll see the server starting up inside the console at the bottom of the screen.
- To test to see if everything is working, open a browser and go to http://localhost:8080 . You should see a message telling you and Wicket is running.
- To stop the server, click the red square at the top right of the console in Eclipse. You may need to stop and start the server after you make programming changes in order for the changes to take effect.
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.
- Open the pom.xml file in the project root directory and scroll toward the bottom, where you'll find: and add the line right after
- 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.