How to quick start wicket project for rapid java web application development (with maven and jetty)
I walked by a friend at school few days ago and noticed he was working on a pet project. I looked over his shoulder for a while and saw he was using PHP and Apache as his development platform. Me, being the Java fan that I am, told him I had always dreamed of writing a little article on how to jump start Java web application since few of my very capable friends haven't been able to dive into Java web development due to the complexity it takes to write the applications, test and deploy them. So I started writing the article yesterday. I started writing and went on and on about maven and how great that is until I hit the preview button and noticed it had turned into ~2 pages worth of maven praising. I'm not going to publish that article, instead I'm going straight to the point.
So to summarize the article that never got, nor will get published:
- Get the latest JDK, currently JDK 6 update 2, if you don't have any JDK setup.
The article will be written with Java 5 in mind(post-publish editing) - Get maven and read at least the 5 minute test and the getting started tutorial
- Maven rocks
- Learn to use a shell
So I'm going to show you how to setup the project itself and maybe I'll write another article soon on how to create a very simple image gallery using that setup.
First of all, let's create the project by running the following command from whatever directory you want the project folder to be created in: mvn archetype:create -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=1.3.0-beta3 -DgroupId=com.foursongs -DartifactId=gallery (one liner)
Now run mvn jetty:run in shell from inside the gallery directory and visit the local wicket website which should be running on your computer by now. Wasn't that easy and painless? Jetty serves up whatever you dish up in your quickstart application without any setup at all.
Before we start programming I recommend you pull up your favourite IDE such as eclipse or intellij and let maven generate a project for you. Stop jetty by pressing ctrl+c and write mvn eclipse:eclipse if you want eclipse project or mvn idea:idea if you want intellij project generated. After that, fire up your IDE, open the new project maven created for you and hack away.
I hope this shows that kick starting a Java web application isn't all that difficult. I recommend you head over to the wicket website and maybe the wicket library website for some example of what wicket can do and what you can do with wicket. Don't hesitate to leave comments if you have any questions regarding maven or wicket.
