Vaadin Hello World Web Application with Maven

In Vaadin hello world example, we will learn to create a simple Vaadin application, and then we will deploy the application in the built-in Jetty server.

1. Creating Vaadin Project using Maven Archetype

Use the below maven command in your workspace to create the simplest Vaadin web application.

$ mvn archetype:generate 

Please update the groupId and artifactId as per your choice.

2. Import Generated Project to IDE

Now import the generated project into the IDE (in my case, it’s eclipse) as an existing Maven project.

Vaadin Hello World Application Project Structure
Vaadin Hello World Application Project Structure

The generated project contains a standard folder structure for any maven web application.

3. Generated files

Along with folder structure, we get given below generated files along with vaadin hello world project.

3.1. pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""



		<!-- If there are no local customisations, this can also be "fetch" or "cdn" -->




					<!-- Exclude an unnecessary file generated by the GWT compiler. -->
							<!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
				<!-- Clean up also any pre-compiled themes -->

			<!-- The Jetty plugin allows us to easily test the development build by
				running jetty:run on the command line. -->

			<!-- Vaadin pre-release repositories -->




package com.howtodoinjava.vaadin.demo;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

 * This UI is the application entry point. A UI may either represent a browser window 
 * (or tab) or some part of an HTML page where a Vaadin application is embedded.
 * <p>
 * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be 
 * overridden to add a component to the user interface and initialize non-component functionality.
public class MyUI extends UI {

    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();
        final TextField name = new TextField();
        name.setCaption("Type your name here:");

        Button button = new Button("Click Me");
        button.addClickListener( e -> {
            layout.addComponent(new Label("Thanks " + name.getValue() 
                    + ", it works!"));
        layout.addComponents(name, button);

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {

3.3. web.xml

If you want to use web.xml file, because your server does not support servlet 3.0 specification, you can use this configuration in web.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
	xmlns="" xmlns:xsi=""



Do not forget to remove @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) if you are using web.xml file.

4. Build the Project

Now it’s time to build the project so that it can download all the dependencies and include them into the project’s runtime.

$ mvn clean install

The above maven command will download the dependencies (it will take some time), and build the war file VaadinExample-1.0.war.

5. Run and Test Vaadin Hello World Application

Now it’s time to run the application. In the command prompt, run the following command to start included jetty server.

$mvn jetty:run

This will start the built-in jetty server and you can access the application at http://localhost:8080/.

Vaadin Hello World Screen
Vaadin Hello World Screen

Now fill in your name or any string in the text box and click on the button. It will print the message below the button.

Vaadin Hello World Screen -2
Vaadin Hello World Screen -2

Happy Learning !!


Vaadin Archetypes
Vaadin Maven Setup


Notify of
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.