Installing and Running Jetty

July 6, 2011 | By | 9 Comments

This tutorial will walk you through how to download, install and run Jetty – 100 % Java HTTP and Servlet Container.

If you do not know Jetty, Following is what Wikipedia says about it:

Jetty is a pure Java-based HTTP server and servlet container (Application server) developed as a free and open source project as part of the Eclipse Foundation. It is currently used in products such as ActiveMQ,[1] Alfresco[2] Apache Geronimo,[3] Apache MavenGoogle App Engine,[4] Eclipse,[5] FUSE,[6] HP OpenViewJBoss,[7] Liferay,[8] UbuntuTwitter’s Streaming API[9] and Zimbra.[10] Jetty is also used as a standard Java application server by many open source projects such as Eucalyptus and Hadoop.

I am doing some experiments, and I decided to use Jetty instead of TomCat.

So let’s get this server up and running!

1 – Downloading

You can download Jetty from two sources: Eclipse or Codehaus.

  1. http://jetty.codehaus.org/jetty/
  2. http://www.eclipse.org/jetty/downloads.php

The current stable version is 7, so I downloaded this one from Eclipse page.

The compressed file is platform independent. So if you use Mac, Linux or Windows, that is ok, it will run on any OS.

2 – Installing

Simply uncompress the file to a directory. You should have something like this:

Jetty loiane 01 Installing and Running Jetty

Installation is complete! Let’s get it running.

3 – Running Jetty

  1. Open a terminal.
  2. Go to the Jetty installation directory.
  3. Enter the following command:
java -jar start.jar

Jetty loiane 13 Installing and Running Jetty

Now open a browser and go to localhost to check if Jetty was installed sucessfully:


http://localhost:8080/

You should get a page like this:

Jetty loiane 02 Installing and Running Jetty

And it is done!

Happy coding!

Filed in: Jetty | Tags:

Comments (9)

  1. MPorras

    Cool. So, how do you add it to Eclipse Indigo?

  2. @MPorras – it is going to be the next tutorial, next week! :)

  3. flotin

    Jetty, is a has-been wonderful servlet engine purchased by Eclipse and butchered by Eclipse. It used to be an innovative, have numerous releaseses and a supportive team. Since the the beurocratic, idiotic Eclipse management took over, it has become a sluggered product. Shame. If you are Eclipse and mgr and reading this, please take note: you are dispised.

  4. jac

    I have an error message as follow:
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\aboubacr>cd desktop

    C:\Users\aboubacr\Desktop>dir
    Volume in drive C is Windows7_OS
    Volume Serial Number is E0A8-2E27

    Directory of C:\Users\aboubacr\Desktop

    04/09/2011 03:38 PM .
    04/09/2011 03:38 PM ..
    25/08/2011 07:11 PM 12,910 2011-08-25-TechnicienLaboLallemand.pdf
    03/09/2011 02:07 AM 123,810 37397364-A-Tutorial-for-Spring-Hibernate-
    JSF-Richfaces.pdf
    03/09/2011 01:47 AM 2,722,448 57826250-practical-richfaces-978143021055
    9-44872.pdf
    03/09/2011 01:56 AM 6,884,918 8631933-Richfaces-Reference.pdf
    12/08/2011 07:18 AM 714 aboubacr – Shortcut.lnk
    13/08/2011 10:37 PM 1,129 Adobe ColdFusion Builder.lnk
    14/08/2011 02:18 AM 1,252 Adobe Dreamweaver CS5.lnk
    26/08/2011 11:23 PM 1,273 Adobe Flash Builder 4.5.lnk
    14/08/2011 02:18 AM 1,176 Adobe Flash Professional CS5.lnk
    14/08/2011 02:18 AM 1,092 Adobe Photoshop CS5 (64 Bit).lnk
    12/08/2011 07:53 PM 1,844 Athan.lnk
    18/08/2011 05:41 PM 573 BlueJ.lnk
    12/08/2011 07:17 AM 355 Computer – Shortcut.lnk
    14/08/2011 02:17 AM 2,495 Crystal Reports XI Release 2.lnk
    29/08/2011 10:40 PM 1,475 eclipseIBM.lnk
    22/08/2011 12:09 PM 1,149 Eclip_Indigo.lnk
    22/08/2011 02:45 PM 1,093 eclip_OEPE.lnk
    03/09/2011 01:29 PM 4,165 eeee.txt
    18/08/2011 04:26 AM 1,013 JDeveloper Studio 11.1.1.5.0.lnk
    14/08/2011 02:20 AM 1,389 Microsoft Visual Studio 2010.lnk
    14/08/2011 02:20 AM 2,679 MyEclipse 8.6.lnk
    30/01/2008 02:12 AM 3,143,680 mymdd.exe
    15/08/2011 04:14 PM 2,249 MySQL Workbench 5.2 CE.lnk
    12/08/2011 07:17 AM 351 Network – Shortcut.lnk
    14/08/2011 02:20 AM 2,132 PowerDesigner.lnk
    13/08/2011 02:25 AM 262 Run.lnk
    12/08/2011 07:42 PM 1,114 Screen VidShot.lnk
    28/08/2011 01:53 AM Sudaiss
    12/08/2011 07:44 PM 1,111 SWF Opener.lnk
    28 File(s) 12,919,851 bytes
    3 Dir(s) 126,689,124,352 bytes free

    C:\Users\aboubacr\Desktop>cd..

    C:\Users\aboubacr>dir
    Volume in drive C is Windows7_OS
    Volume Serial Number is E0A8-2E27

    Directory of C:\Users\aboubacr

    30/08/2011 11:09 PM .
    30/08/2011 11:09 PM ..
    18/08/2011 06:51 PM 96 .asadminpass
    22/08/2011 12:09 PM .eclipse
    30/08/2011 11:12 PM .freemind
    15/08/2011 11:45 PM .m2
    13/08/2011 01:07 AM .myeclipse
    13/08/2011 01:08 AM 124 .myeclipse.properties
    22/08/2011 04:21 PM .nbi
    22/08/2011 04:22 PM .netbeans
    17/08/2011 06:56 PM .netbeans-derby
    13/08/2011 12:59 AM 40 .pulse2.locator
    13/08/2011 10:38 PM Adobe ColdFusion Builder workspace
    13/08/2011 02:32 AM Adobe Flash Builder 4
    26/08/2011 11:21 PM Adobe Flash Builder 4.5
    16/08/2011 01:31 AM bluej
    11/08/2011 05:14 PM Contacts
    04/09/2011 03:38 PM Desktop
    29/08/2011 10:21 PM 45 dlmgr_.pro
    19/08/2011 06:01 PM Documents
    29/08/2011 10:38 PM DownloadDirector
    04/09/2011 03:37 PM Downloads
    23/08/2011 10:07 PM Favorites
    11/08/2011 05:14 PM Links
    11/08/2011 05:14 PM Music
    19/08/2011 01:47 AM New folder
    15/08/2011 06:22 PM Pictures
    12/08/2011 09:03 PM Roaming
    11/08/2011 05:14 PM Saved Games
    11/08/2011 05:14 PM Searches
    12/08/2011 07:41 PM Videos
    22/08/2011 10:09 PM workspace
    29/08/2011 10:41 PM Workspaces
    4 File(s) 305 bytes
    29 Dir(s) 126,688,878,592 bytes free

    C:\Users\aboubacr>cd..

    C:\Users>cd..

    C:\>dir
    Volume in drive C is Windows7_OS
    Volume Serial Number is E0A8-2E27

    Directory of C:\

    15/08/2011 07:18 PM bea
    18/08/2011 05:41 PM BlueJ
    12/08/2011 07:31 AM extensions
    24/07/2011 09:32 PM Intel
    24/07/2011 09:06 PM mfg
    02/12/2006 02:37 AM 904,704 msdia80.dll
    15/08/2011 07:15 PM Oracle
    15/08/2011 04:24 PM oraclexe
    15/08/2011 04:47 PM PerfLogs
    12/08/2011 08:02 PM Perl
    22/08/2011 04:11 PM Program Files
    30/08/2011 11:09 PM Program Files (x86)
    24/07/2011 09:35 PM 2,993 RHDSetup.log
    22/08/2011 11:32 AM swshare
    12/08/2011 09:05 PM SWTOOLS
    11/08/2011 05:10 PM Users
    01/09/2011 08:08 PM Windows
    2 File(s) 907,697 bytes
    15 Dir(s) 126,688,878,592 bytes free

    C:\>cd Program Files

    C:\Program Files>cd java

    C:\Program Files\Java>dir
    Volume in drive C is Windows7_OS
    Volume Serial Number is E0A8-2E27

    Directory of C:\Program Files\Java

    04/09/2011 03:38 PM .
    04/09/2011 03:38 PM ..
    22/08/2011 04:20 PM Apache Software Foundation
    22/08/2011 12:44 PM apache-tomcat-7.0.20
    22/08/2011 11:52 AM EclipseIndigoJavaEE
    23/08/2011 11:37 AM EclipseOEPE
    22/08/2011 04:20 PM glassfish-3.1.1
    19/08/2011 06:09 AM Jboss 5.0
    18/08/2011 05:31 PM jdk1.5.0_22
    18/08/2011 05:34 PM jdk1.6.0_27
    18/08/2011 05:37 PM jdk1.7.0
    01/09/2011 11:34 AM jetty-distribution-7.5.0.v20110901
    18/08/2011 05:34 PM jre6
    18/08/2011 05:37 PM jre7
    13/06/2011 01:03 PM mojarra-2.1.2-FCS
    22/08/2011 04:49 PM Primefaces
    0 File(s) 0 bytes
    16 Dir(s) 126,688,972,800 bytes free

    C:\Program Files\Java>cd jetty
    The system cannot find the path specified.

    C:\Program Files\Java>dir
    Volume in drive C is Windows7_OS
    Volume Serial Number is E0A8-2E27

    Directory of C:\Program Files\Java

    04/09/2011 03:46 PM .
    04/09/2011 03:46 PM ..
    22/08/2011 04:20 PM Apache Software Foundation
    22/08/2011 12:44 PM apache-tomcat-7.0.20
    22/08/2011 11:52 AM EclipseIndigoJavaEE
    23/08/2011 11:37 AM EclipseOEPE
    22/08/2011 04:20 PM glassfish-3.1.1
    19/08/2011 06:09 AM Jboss 5.0
    18/08/2011 05:31 PM jdk1.5.0_22
    18/08/2011 05:34 PM jdk1.6.0_27
    18/08/2011 05:37 PM jdk1.7.0
    01/09/2011 11:34 AM jetty_dist7.5
    18/08/2011 05:34 PM jre6
    18/08/2011 05:37 PM jre7
    13/06/2011 01:03 PM mojarra-2.1.2-FCS
    22/08/2011 04:49 PM Primefaces
    0 File(s) 0 bytes
    16 Dir(s) 126,688,972,800 bytes free

    C:\Program Files\Java>cd jetty_dist7.5

    C:\Program Files\Java\jetty_dist7.5>dir
    Volume in drive C is Windows7_OS
    Volume Serial Number is E0A8-2E27

    Directory of C:\Program Files\Java\jetty_dist7.5

    01/09/2011 11:34 AM .
    01/09/2011 11:34 AM ..
    01/09/2011 11:34 AM 1,614 about.html
    01/09/2011 11:34 AM bin
    01/09/2011 11:18 AM contexts
    01/09/2011 11:34 AM contexts-available
    01/09/2011 11:18 AM etc
    01/09/2011 11:34 AM lib
    01/09/2011 11:34 AM 11,358 LICENSE-APACHE-2.0.txt
    01/09/2011 11:34 AM 16,560 LICENSE-ECLIPSE-1.0.html
    01/09/2011 11:34 AM logs
    01/09/2011 11:34 AM 6,262 notice.html
    01/09/2011 11:18 AM overlays
    01/09/2011 11:34 AM 1,490 README.txt
    01/09/2011 11:34 AM resources
    01/09/2011 11:34 AM 2,199 start.ini
    01/09/2011 11:34 AM 43,149 start.jar
    01/09/2011 11:34 AM 226,479 VERSION.txt
    01/09/2011 11:34 AM webapps
    8 File(s) 309,111 bytes
    11 Dir(s) 126,688,972,800 bytes free

    C:\Program Files\Java\jetty_dist7.5>java -jar start.jar
    java.lang.ClassNotFoundException: org.eclipse.jetty.xml.XmlConfiguration
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:438)
    at org.eclipse.jetty.start.Main.start(Main.java:612)
    at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
    at org.eclipse.jetty.start.Main.main(Main.java:79)
    ClassNotFound: org.eclipse.jetty.xml.XmlConfiguration

    Usage: java -jar start.jar [options] [properties] [configs]
    java -jar start.jar –help # for more information

    C:\Program Files\Java\jetty_dist7.5>

  5. jac

    C:\Program Files\Java\jetty_dist7.5>java -jar start.jar
    java.lang.ClassNotFoundException: org.eclipse.jetty.xml.XmlConfiguration
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:438)
    at org.eclipse.jetty.start.Main.start(Main.java:612)
    at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
    at org.eclipse.jetty.start.Main.main(Main.java:79)
    ClassNotFound: org.eclipse.jetty.xml.XmlConfiguration

    Usage: java -jar start.jar [options] [properties] [configs]
    java -jar start.jar –help # for more information

    C:\Program Files\Java\jetty_dist7.5>

  6. Pouts

    Try to install jetty on directory without space (for windows OS)

    ex : c:\jetty_dist7.5

Leave a Reply

Trackback URL | RSS Feed for This Entry