Create a Vaadin Mobile App Project in Eclipse
The Fitness Library Application in More Detail
The application that we'll be building manages a collection of fitness exercises - something that all of us desk jockeys are in dire need of! New exercises may be added using a GUI form. All of the stored exercises will be listed below the input fields. If that sounds familiar to you, it's because it's the same app that we began constructing as a Java Enterprise Application in the Create a Java EE Web Application using the Glassfish Server article and subsequent follow-up, Persistence in Java EE Applications. And why not? It's precisely the kind of app that you'd want to make available to your mobile devices.
Developing with Vaadin
There are several installation options available to you. The Vaadin team is partial to using Maven, but they also provide plug-ins for Eclipse and NetBeans, for those of us who don't use maven. Finally, there is an all-in-one archive file that contains everything you need. This option is suitable for those who want maximum control over the installation process and would rather manage the files manually.
What You'll Need
The software that you'll need for this tutorial is almost exactly the same as for the two Java EE articles referenced above, except of course for the addition of the Vaadin plug-in:
- Java JDK 6.0 (or above)
- Eclipse IDE
- GlassFish Server 3.0.1 (or above)
- Vaadin Eclipse plug-in
ObjectDB is an easy to use pure Java Object Database.
Note that ObjectDB 2.3.7_04 or later is required if Glassfish 3.1.2 (or later) is used.
Getting up-and-running in Eclipse
If you happen to be running Eclipse Indigo, you're in luck because the Eclipse Plugin page has an icon that can be dragged directly into your workspace to start the installation. For the rest of us, I would go with Eclipse's excellent Install New Software feature. Here's how:
- Select Install New Software… from the Help menu
- Add one of the following URLs for the update site:
Eclipse 3.5 and newer: http://vaadin.com/eclipse
Eclipse 3.4: http://vaadin.com/eclipse/3.4
Note that Visual Designer is not available in the Eclipse 3.4 version.
- Select the features you want to install and click Next to continue with the installation.
You can also install the Vaadin Plug-in directly from the Eclipse Marketplace or alternatively, you can download an offline installation package for Vaadin 6 from the server.
By the way, there is a serious bug (#445122) in Eclipse LUNA SR1 (4.4.1) that affects not only Vaadin, but many other projects as well! Since that it exactly the version that I am running, I am going to go over how to apply the hotfix:
- Select Help -> Install New Software from the main menu
- Select "The Eclipse Project Updates" in the Work with dropdown
- Check the "Patch for 445122" box
- Leave the defaults in the "Install Remediation Page"
- Restart Eclipse when prompted
If you encounter any difficulties, you might want to check out the video instructions on Youtube.
Creating a Vaadin Project
Once you've got the Vaadin plug-in all set up, you're ready to create a Vaadin project via File > New > Other… from the main menu.
On the Select a wizard dialog, expand the Vaadin folder and select "Vaadin 7 Project".
Click Next >.
The next screen is where you configure your project settings.
Give your project a name of "ExercisesMobileApp".
If you haven't yet configured your Glassfish runtime environment, you'll need to do that now. Follow the instructions in the Setting the Target Runtime section of the Create a Java EE Web Application using the Glassfish Server article.
Pick your Glassfish 4 runtime as the Target Runtime and keep all of the other defaults.
Click Finish to create the project.
We are now ready build our app! In next month's article, we'll begin with the coding of the User Interface (UI).
Rob Gravelle resides in Ottawa, Canada, and is the founder of GravelleWebDesign.com. Rob has built systems for Intelligence-related organizations such as Canada Border Services, CSIS as well as for numerous commercial businesses.
In his spare time, Rob has become an accomplished guitar player, and has released several CDs. His band, Ivory Knight, was rated as one Canada's top hard rock and metal groups by Brave Words magazine (issue #92) and reached the #1 spot in the National Heavy Metal charts on Reverb Nation.