Install Jetty 9 on Ubuntu Server 18.04 LTS

Ubuntu 18 Install Jetty

Jetty 9 is a HTTP server just like Apache 2 or Nginx, and a Java servlet engine just like Apache Tomcat.

Jetty 9 has support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and many more out of the box.

Jetty is open source, flexible and extensible. Jetty works asynchronously and due to its smaller footprint, it can be used in embedded devices as well.

It is one of the best enterprise grade web server for Java based technologies.

In this article, I am going to show you how to install Jetty 9 on Ubuntu Server 18.04 LTS. Let’s get started.

Upgrading Packages:

It’s best to upgrade all the packages of your Ubuntu Server 18.04 LTS before installing new software packages. That way you can get all the bug fixes and security updates.

First update the APT package repository cache with the following command:

$ sudo apt update

The APT package repository cache should be updated. It says All the packages are up to date. If you have new package updates, you should see it here.

If you do have new package updates, then run the following command to update them:

$ sudo apt upgrade

As I don’t have new package updates, none is upgraded.

Installing OpenJDK:

Jetty 9 depends on Java Development Kit (JDK). You can install Oracle JDK or OpenJDK depending on your choice.

As OpenJDK is available in the official package repository of Ubuntu Server 18.04 LTS, this is what I prefer unless you have specific reason to use Oracle JDK.

Run the following command to install OpenJDK:

$ sudo apt install openjdk-8-jdk

Now press y and then press to continue. OpenJDK should be installed.

You can check whether OpenJDK works with the following command:

$ javac -version

It works!

Installing Jetty 9:

Jetty 9 is available in the official package repository of Ubuntu Server 18.04 LTS.

To install Jetty 9, run the following command:

$ sudo apt install jetty9

Now press y and then press to continue. Jetty 9 should be installed.

Starting Jetty 9 and Adding Jetty 9 to the System Startup:

Now you can check whether jetty9 service is running with the following command:

$ sudo systemctl status jetty9

As you can see, jetty9 service is running.

If jetty9 service is not running, run the following command to start it:

$ sudo systemctl start jetty9

If you want jetty9 service to start when your computer boots, run the following command to add it to the system startup:

$ sudo systemctl enable jetty9

Testing Jetty 9:

Jetty 9 runs on port 8080 by default. You can visit http://localhost:8080 from your Ubuntu Server 18.04 LTS where you installed Jetty 9 to see whether it works.

I used CURL to request http://localhost:8080 from the command line.

$ curl http://localhost:8080

As you can see, it works.

Install Jetty on Ubuntu

If you want to connect to your Jetty 9 server from another computer on the network, first you have to find out the IP address of your Ubuntu Server 18.04 LTS where you installed Jetty 9 with the following command:

$ ip a

As you can see, the IP address is 192.168.199.129 in my case.

Now visit http://192.168.199.129:8080 from any web browser on the network and it should work.

Install Jetty 9 on Ubuntu 18

That’s how you can install Jetty on your Ubuntu Server within few minutes. I hope you like this tutorial, please share this article with your colleagues.

If you want how to article like this, please leave comment with the topic you want me to write.

LEAVE A REPLY

Please enter your comment!
Please enter your name here