A personal and Java blog, likely only for me

Getting started with Vert.x


What is Vert.x?

In my humble opinion, Vert.x is a poorly documented platform for creating server applications intended to be scalable by using an event-driven, non-blocking I/O in the JVM.

The first definition for Vert.x I heard was “it’s like Node.js but in the JVM”. (Yeah!, part of my first definition has been copied from the description that can be found at Node.js)

OK! Let’s take a look to the Vert.x site:

“Vert.x is a lightweight, high performance application platform for the JVM that’s designed for modern mobile, web, and enterprise applications.”

Terrific! Furthermore:

  • It’s polyglot: you can write your application components in Java, JavaScript, CoffeeScript, Ruby, Python or Groovy. And you can even mix all these languages. Sincerely, I don’t find this feature exciting.
  • It has a simple APIs for writing non-blocking network enabled applications.
  • It’s scalable because it uses non blocking I/O to serve many connections with minimal threads plus passing messages to handle the logic of the application.
  • It provides a simple actor-like concurrency model, so that you don’t have to worry about multi-threaded programming anymore.

Well! I still miss something here.

Taking a look to the Key Features you’ll learn that Vert.x has an Event Bus, a kind of Queue that will use the Vert.x components, called Verticles, to communicate between them regardless their programming language. It uses WebSockets and SockJS to achieve the JavaScript penetration that they claim.

Vert.x is a platform that you invoke from the command line, vert.x run for single Verticles or vert.x runmod for the encapsulation system that Vert.x provides: the module system (that can be shared via Maven repository or Bintray and can be registered in the module registry). But it also can be embedded in a Java application.

Install Vert.x

Installing Vert.x is very easy:

  1. You need a Linux, OS X or Windows with JDK 1.7.0 or later installed (try javac -version in order to ensure that you have the JDK bin directory on your PATH).
  2. Download the latest release of Vert.x, 2.1.1 at the time of this writing.
  3. Decompress the download file. I like to have an Applications directory in my home directory, so: tar -zxf ~/Applications/vert.x-2.1.1.tar.gz will work right.
  4. Add the Vert.x bin directory to your PATH environment variable.

Now you can check the version:

The first example

Testing the install is as easy as write a simple web server. This example will show the main features of Vert.x: simplicity, scalability, concurrency. With a few more examples, the polyglot would be showed as well.

Copy the following into a text editor and save it as

Now run this Verticle (more on the Vert.x concepts later) by opening a console in the directory where you saved the file, and typing:

To ensure that you have really succeeded with this verticle, open a web browser and go to http://localhost:8080 (see above the highlighted line 15, if you want to change the port number)

You have to see “Hello World!” (without the quotes)

Hello world from Vert.x

Hello vert.x

Now you can stop the server by using Ctrl+C (Command-C in OS X)

Regarding polyglot, you can find more or less the same sample at in JavaScript, Ruby, Groovy, Python and Clojure

You can see with this example another feature of Vert.x: you don’t need to compile Java code. I suppose that the authors wanted to give the same facilities that the other languages have, but they are script languages. I don’t find interesting this option, and it’s totally useless for big projects, that is better to be distributed as modules.

Next steps

We have seen almost nothing of Vert.x but the installation and a dumb test. In later posts, I will explain the Core Concepts and I will develop a Java Vert.x application using maven.

Author: Javier (@jbbarquero)

Java EE developer, swim addict, occasional videogames player, fan of Ben Alex and Shamus Young, and deeply in love with my wife. Sooner or later I'll dedicate a post to expand this simple introduction.

Leave a Reply

Required fields are marked *.