ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 01.01.2026
Просмотров: 2610
Скачиваний: 0
Chapter 2
Getting Started
with Vaadin
2.1. Overview .................................................................................................. |
27 |
2.2. Setting up the Development Environment ............................................... |
28 |
2.3. Overview of Vaadin Libraries ................................................................... |
32 |
2.4. Installing Vaadin Plugin for Eclipse .......................................................... |
33 |
2.5. Creating and Running a Project with Eclipse .......................................... |
36 |
2.6. Using Vaadin with Maven ......................................................................... |
46 |
2.7. Creating a Project with NetBeans IDE ..................................................... |
48 |
2.8. Vaadin Installation Package ..................................................................... |
49 |
This chapter gives practical instructions for installing the recommended toolchain, the Vaadin libraries and its dependencies, and creating a new Vaadin project.
2.1. Overview
You can develop Vaadin applications in essentially any development environment that has the Java SDK and a Java Servlet container. Vaadin has special support for the Eclipse IDE, but community support exists also for the NetBeans IDE and IntelliJ IDEA, and you can use it with any Java IDE or no IDE at all.
Managing Vaadin and other Java libraries can get tedious to do manually, so using a build system that manages dependencies automatically is adviced. Vaadin is distributed in the Maven central
Book of Vaadin |
27 |
Getting Started with Vaadin
repository, and can be used with any build or dependency management system that can access Maven repository, such as Ivy or Gradle, in addition to Maven.
Vaadin has a multitude of installation options for different IDEs, dependency managers, and you can also install it from an installation package:
•With the Eclipse IDE, use the Vaadin Plugin for Eclipse, as described in Section 2.4, “Installing Vaadin Plugin for Eclipse”
•With the Vaadin plugin for NetBeans IDE (Section 2.7, “Creating a Project with NetBeans IDE”) or IntelliJ IDEA
•With Maven, Ivy, Gradle, or other Maven-compatible dependency manager, under Eclipse, NetBeans, IDEA, or using command-line, as described in Section 2.6, “Using Vaadin with Maven”
•From installation package without dependency management, as described in Section 2.8, “Vaadin Installation Package”
2.2.Setting up the Development Environment
This section guides you step-by-step in setting up a reference development environment. Vaadin supports a wide variety of tools, so you can use any IDE for writing the code, almost any Java web server for deploying the application, most web browsers for using it, and any operating system platform supported by Java.
In this example, we use the following toolchain:
•Windows XP [http://www.microsoft.com/windowsxp/], Linux, or Mac OS X
•Sun Java 2 Standard Edition 6.0 [http://java.sun.com/javase/downloads/index.jsp] (JDK 1.6 or newer is required)
•Eclipse IDE for Java EE Developers [http://www.eclipse.org/downloads/]
•Apache Tomcat 7.0 (Core) or newer [http://tomcat.apache.org/]
•Mozilla Firefox [http://www.getfirefox.com/] browser
•Firebug [http://www.getfirebug.com/] debug tool (optional)
•Vaadin Framework [http://vaadin.com/download/]
The above reference toolchain is a good choice of tools, but you can use almost any tools you are comfortable with.
28 |
Setting up the Development Environment |
Getting Started with Vaadin
Figure 2.1. Development Toolchain and Process
Figure 2.1, “Development Toolchain and Process” illustrates the development environment and process.You develop your application as an Eclipse project. The project must include, in addition to your source code, the Vaadin libraries. It can also include project-specific themes.
You need to compile and deploy a project to a web container before you can use it. You can deploy a project through the Web Tools Platform (WTP) for Eclipse (included in the Eclipse EE package), which allows automatic deployment of web applications from Eclipse. You can also deploy a project manually, by creating a web application archive (WAR) and deploying it to the web container.
2.2.1. Installing Java SDK
Java SDK is required by Vaadin and also by the Eclipse IDE. Vaadin is compatible with Java 1.6 and later editions.
Windows
1.Download Sun Java 2 Standard Edition 6.0 from http://java.sun.com/javase/downloads/index.jsp [http://java.sun.com/javase/downloads/index.jsp]
2.Install the Java SDK by running the installer. The default options are fine.
Linux / UNIX
Most Linux systems either have JDK preinstalled or allow installing it through a package management system. Notice however that they have OpenJDK as the default Java implementation. While it is known to have worked with Vaadin and possibly also with the development toolchain, we do not especially support it.
Installing Java SDK |
29 |
Getting Started with Vaadin
Regarding OS X, notice that JDK 1.6 or newer is included in OS X 10.6 and newer. Otherwise:
1.Download Sun Java 2 Standard Edition 6.0 from http://java.sun.com/javase/downloads/index.jsp [http://java.sun.com/javase/downloads/index.jsp]
2.Decompress it under a suitable base directory, such as /opt. For example, for Java SDK, enter (either as root or with sudo in Linux):
#cd /opt
#sh (path-to-installation-package)/jdk-6u1-linux-i586.bin
and follow the instructions in the installer.
3.Set up the JAVA_HOME environment variable to point to the Java installation directory. Also, include the $JAVA_HOME/bin in the PATH. How you do that varies by the UNIX variant. For example, in Linux and using the Bash shell, you would add lines such as the following to the .bashrc or .profile script in your home directory:
export JAVA_HOME=/opt/jdk1.6.0_29
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
You could also make the setting system-wide in a file such as /etc/bash.bashrc, /etc/profile, or an equivalent file. If you install Apache Ant or Maven, you may also want to set up those in the path.
Settings done in a bashrc file require that you open a new shell window. Settings done in a profile file require that you log in into the system. You can, of course, also give the commands in the current shell.
2.2.2. Installing Eclipse IDE
Windows
1.Download the Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/ [http://www.eclipse.org/downloads/]
2.Decompress the Eclipse IDE package to a suitable directory.You are free to select any directory and to use any ZIP decompressor, but in this example we decompress the ZIP file by just double-clicking it and selecting "Extract all files" task from Windows compressed folder task. In our installation example, we use C:\dev as the target directory.
Eclipse is now installed in C:\dev\eclipse and can be started from there (by double clicking eclipse.exe).
Linux / OS X / UNIX
We recommend that you install Eclipse manually in Linux and other UNIX variants as follows.
1.Download Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/ [http://www.eclipse.org/downloads/]
2.Decompress the Eclipse package into a suitable base directory. It is important to make sure that there is no old Eclipse installation in the target directory. Installing a new version on top of an old one probably renders Eclipse unusable.
30 |
Installing Eclipse IDE |