Sven Ruppert

How to develop Vaadin apps without servlet container restarts


Vaadin Flow is based on Java and a Servlet-Container. To see results, you need to deploy the Flow app, and the servlet container must run. This startup will take a few seconds based on your computer and the project. How could we get this turnaround time reduced? What should we do to speed up the development? The answer is called DCEVM and Hotswap.

What is DCEVM?

DCEVM is an extension to the JVM that will allow us to reload classes at runtime more easily. It is based on the OpenJDK version 8 and 11 so far. Maybe, more versions are available in the future. Check the DCEVM-website for this To use this, you need to download the version you need (version 8 or 11) also, start the installer with the command. java -jar installer.jar Follow the instructions that the UI will give you. To make it easier to switch between a JDK with and without DCEVM you should use a dedicated installation of the JDK for this. The primary process is the following:

  • java -jar installer.jar

  • press the button "Add installation directory."

  • select the folder of the JDK you want to use

  • decide if you’re going to have it as a replacement and/or alternative JVM configuration

  • close the app

Select the JDK root directory
Select replace and/or as altjvm


After this is done, we need the second part called HotSwapAgent In contrast to standard Java, where the hot-swap is limited to in-body code changes, the DCEVM + HotswapAgent allow following code changes:

  • Add/remove/modify class fields.

  • Add/remove/modify methods. Add/remove/modify method annotations

  • Add/remove/modify classes including anonymous classes. HotswapAgent handless correct anonymous class redefinitions.

  • Add/remove a static member of classes. HotswapAgent handles static member initialization.

  • Add/remove enum values

  • Refresh framework and application server settings

The only unsupported operation is hierarchy change (change the superclass or remove an interface). DCEVM does hot-swap on JVM level. HotwapAgent does the same on the level of Java frameworks and servlet containers.

To activate HotSwapAgent, download the binary for your JDK (version 8 or 11 is supported right now) and enable this agent during the start of the JVM. -javaagent:hotswap-agent.jar There are a lot of different Plugins available; Vaadin Support is one of them.

How to develop with this?

If you are done with these preparations, you should start your Vaadin project in Debug mode using the DCEVM extended JDK. Do not forget to activate the HotSwapAgend (-javaagent:hot-swap-agent.jar) After you changed a class, re-compile it and refresh the Flow web app in the browser. That is it.

DCEVM/Hotsap in practice


You are now able to develop a Vaadin Flow web app with short roundtrip times. If you want to try this by yourself, have a look at the starter packs and try it by yourself.

Happy Coding

Vaadin is an open-source framework offering the fastest way to build web apps on Java backends

Comments (0)