ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install Jetty 8 on Ubuntu 14.04

Overview

Jetty is an open source Java HTTP Web Server and Java Servlet Container. Usually a web server or application server is used to serve content to people, Jetty on the other hand usually is used for machine to machine communication.

Jetty is developed as an open source application under the Eclipse Foundation project. In this tutorial we'll learn how-to install Jetty 8 on Ubuntu 14.04 from scratch. This tutorial assumes you have clean installation of Ubuntu 14.04.

Updating the Base System

To make sure that our system is secure, the first thing that we want to do to our base system is to update the system to latest packages. To do this, run the following:

$ sudo apt-get update
$ sudo apt-get upgrade

After updating the base system to latest release, we're ready to install the prerequisite of Jetty 8.

Installing JDK 8

Jetty needs Java to run. We will use Oracle JDK 8 instead of OpenJDK in this tutorial. We will install JDK 8 using Webupd8 team PPA.

Add the webupd8team ppa repository :

$ sudo add-apt-repository ppa:webupd8team/java

Press [ENTER] to continue or ctrl-c to cancel adding it

OK

You need to press enter to continue adding the webupd8team PPA repository. The output above has been truncated to show you only the most important parts.

Let apt-get download and read the metadata of the new repository that we just added:

$ sudo apt-get update

Install JDK 8.

$ sudo apt-get -y install oracle-java8-installer

the -y option above will make you agree automatically with packages to be installed including dependencies. If you want to check what packages will be installed you can remove the -y option.

Package configuration. Choose OK

Accepting Oracle Binary Code License Terms. Choose Yes

After installing Java 8, you can check the current java version by running command below :

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

We've confirmed that we have JDK 8 installed.

Install Jetty 8

All the prerequisite already installed. Now we can install Jetty 8 from Repository.

$ sudo apt-get install jetty8

Configure Jetty

Jetty 8 is installed but it's not ready yet because by default it's disabled. If you try to start the service you will get a warning.

$ sudo service jetty8 start
 * Not starting jetty - edit /etc/default/jetty8 and change NO_START to be 0 (or comment it out).

To enable Jetty so that we can start the service, edit /etc/defaults/jetty8. On line 4 you'll find :

NO_START=1

Change it to :

NO_START=0

Let's start the service

$ sudo service jetty8 start
' * Starting Jetty servlet engine. jetty8                                                                                                                      * Jetty servlet engine started, reachable on http://two.testserver.pw:8080/. jetty8                                                                   [ OK ] 

If you are installing Jetty on computer that you currently use you can open http://localhost:8080. If you are installing Jetty on remote computer you are not able to access Jetty yet, for example when you access http://:8080.

Let's check where Jetty 8 listens :

$ sudo netstat -naptu | grep 8080
tcp6       0      0 127.0.0.1:8080          :::*                    LISTEN      8409/java    

Jetty is already listen on port 8080 but only on 127.0.0.1 or localhost. That's why we cannot access it from remote server. We'll make Jetty listen to all interfaces. Open file vi /etc/jetty8/jetty.xml. Find line below (line 39):


Change it to the below :

0.0.0.0

If you want Jetty to listen to a specific IP address, for example 192.168.100.100, you can change it to :

192.168.100.100

Now, let's restart the Jetty 8 service :

$ sudo service jetty8 restart
 * Stopping Jetty servlet engine (was reachable on http://two.testserver.pw:8080/). jetty8                                                                     * Jetty servlet engine stopped. jetty8                                                                                                                [ OK ] 
 * Starting Jetty servlet engine. jetty8                                                                                                                       * Jetty servlet engine started, reachable on http://two.testserver.pw:8080/. jetty8                                                                   [ OK ] 

Let's check where Jetty8 listens :

$ sudo netstat -naptu | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      8589/java   

Jetty8 is listening on all interfaces and IP address. Now, you can open http://:8080. You will see a welcome page of Jetty:

Summary

In this tutorial we learned how-to install Jetty 8 on Ubuntu 14.04. We learned how-to update the server to latest update, install JDK 8 from Oracle then install and configure Jetty 8. Now you can start deploying your Java app to Jetty. Have Fun!

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans