<\/span><\/h2>\r\nJetty 9 depends on the Java Development Kit (JDK).\u00a0We can check if Java is already installed using this command:<\/p>\r\n
which java<\/pre>\r\nIf there is no output, it means that Java is not installed on the server yet.<\/p>\r\n
You can install\u00a0Oracle JDK<\/strong>\u00a0or\u00a0OpenJDK<\/strong> depending on your choice. We’ll use\u00a0OpenJDK<\/strong>, as that’s what\u00a0is readily available in the pre-installed Ubuntu package repositories. They are functionally identical, so choosing either one will not affect how the program runs. We also included the Oracle JDK install further down below if necessary.<\/p>\r\nYou can install OpenJDK with the following command:<\/p>\r\n
$ sudo apt install openjdk-8-jdk<\/pre>\r\nTo check if everything is set correctly, run this next line:<\/p>\r\n
$ java -version<\/pre>\r\nAfter which you should see something like the following:<\/p>\r\n
openjdk version \"1.8.0_212\"\r\nOpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)\r\nOpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)\r\n<\/pre>\r\nIf however, you have a specific reason to use the Oracle JDK, this command will install Oracle JDK 8 using the PPA repository:<\/p>\r\n
$ sudo add-apt-repository ppa:webupd8team\/java\r\n$ sudo apt-get update\r\n$ sudo apt-get install oracle-java8-installer<\/pre>\r\n<\/span>Step 3: Install Jetty 9<\/span><\/h2>\r\nJetty 9 is available in the pre-installed Ubuntu package repositories. You can install it with the following command:<\/p>\r\n
$ sudo apt install jetty9<\/pre>\r\nOnce the installation is complete, Jetty 9 will be automatically started.<\/p>\r\n
To check and verify the installed Jetty version, run the following command:<\/p>\r\n
$ apt show jetty<\/pre>\r\nAt which point you should see something like the following. You might have a later version than the one shown here:<\/p>\r\n
Package: jetty9\r\nVersion: 9.4.15-1~18.04.1ubuntu1\r\nPriority: optional\r\nSection: universe\/java\r\nOrigin: Ubuntu<\/pre>\r\n<\/span>Step 4: Managing the <\/span>Jetty 9 Service<\/span><\/span><\/h2>\r\nEnable the Jetty 9 at boot time using the following command:<\/p>\r\n
$ sudo systemctl enable jetty9<\/pre>\r\nStart Jetty 9 service using this command:<\/p>\r\n
$ sudo systemctl start jetty9<\/pre>\r\nWe can restart Jetty 9 using:<\/p>\r\n
$ sudo systemctl restart jetty9<\/pre>\r\nIn order to stop Jetty 9, we can use this command:<\/p>\r\n
$ sudo systemctl stop jetty9<\/pre>\r\nWe can check the service status using:<\/p>\r\n
$ systemctl status jetty9<\/pre>\r\nThe output of this command should be similar to this:<\/p>\r\n
\u25cf<\/span> jetty9.service - Jetty 9 Web Application Server\r\n Loaded: loaded (\/lib\/systemd\/system\/jetty9.service; enabled; vendor preset: enabled)\r\n Active: active (running)<\/span> \r\n Docs: https:\/\/www.eclipse.org\/jetty\/documentation\/current\/\r\n Main PID: 19382 (java)\r\n Tasks: 24 (limit: 2321)\r\n CGroup: \/system.slice\/jetty9.service\r\n \u2514\u250019382 \/usr\/bin\/java -Djetty.home=\/usr\/share\/jetty9 -Djetty.base=\/usr\/share\/jetty9 -Djava.io.tmpdir=\/tmp -jar \/usr\/share\/jetty9\/start.jar jetty.state=\/var\/lib\/jetty9\/jetty.state jetty-started.xml<\/pre>\r\n