I’ve recently been working on porting Jetty to Google’s mobile platform called Android.

It’s early days still, but I’ve succeeded in running a minimal setup with a connector (I’ve tested both bio and nio connectors) and a simple Handler. If you’d like to take a look, then check out the code from the i-jetty project and build it (you’ll need to execute the ant build script and then use Android’s packaging tool or the Eclipse plugin).

Once you’ve built and deployed the i-jetty package to the emulator,  find the “Manage Jetty” application, and select the “Start Jetty” button. Then you’ll be able to select the Browser application and surf to and hit the demo “Hello” Handler.

For the moment I’ve had to do a teeny hack to the servlet api classes, due to this bug in Android, but hopefully that will be fixed soon and I can revert the temporary patches.

Much work remains to be done, but I thought I’d give everyone early warning that this work was going on. Who knows, it might inspire someone to use Jetty to win the Android developer challenge?!

Jetty Does Android

46 thoughts on “Jetty Does Android

  • February 20, 2008 at 10:36 am

    Great !

  • February 20, 2008 at 9:26 pm

    Nice going Jan!

  • February 29, 2008 at 4:55 am

    Hi Jan,

    Before I found this website I tried to get the embed Jetty into an android app….seems to be having some issues.

    Then I saw your posting while researching a solution.

    Would you be able to give some direction in making your application work within the emulator?

  • February 29, 2008 at 9:44 am

    Hi Mike,

    Its very easy  to get the i-jetty project running. All you need to do is:

    + do an svn checkout of the source.
    svn checkout http://i-jetty.googlecode.com/svn/trunk/ i-jetty-read-only

    + do an ant build to suck in the jetty modules from the jetty repo:
    cd i-jetty-readonly

    + use the Eclipse plugin to build the project (see http://code.google.com/android/intro/installing.html#installingplugin). I haven’t used the command line tools to generate the .apk files yet. When I sort out how to do it, I’ll post the instructions.

    + once you’ve got the bin/i-jetty.apk file built, then you just have to run it in an emulator. The Eclipse plugin will install and run the emulator for you. Otherwise, at the command line, you need to do: 
    $gwt.home/tools/adb install $ijetty.home/bin/i-jetty.apk
    As you’ll see, the current application that is started by the jetty instance uses a number of specific servlet instances to serve content. I’m working on a more flexible, generic way to serve content, particularly content off the sdcard (see the org.mortbay.i-jetty.servlet.DefaultServlet). Content derived from the various ContentProvider instances is probably always going to require some custom coding.


  • March 2, 2008 at 12:27 am

    Hi Jan

    I’m trying to get the i-jetty project running but I can’t build it inside de Eclipse. I’ve installed the Ant Plugin and I’m trying to use it but it’s not working. As I’m not a late user of Eclipse, problably I’m committing mistakes. The error is the following:

    Buildfile: C:Documents and SettingsUserworkspacei-jettybuild.xml

            [echo] Generating src-generated
            [copy] Copying 257 files to C:Documents and SettingsUserworkspacei-jettysrc-generated

    C:Documents and SettingsUserworkspacei-jettybuild.xml:45: java.io.IOException: Cannot run program "patch" (in directory "C:Documents and SettingsUserworkspacei-jettysrc-generated"): CreateProcess error=2, O sistema não pode encontrar o arquivo especificado

    Total time: 1 second

    Any tips?

    Thanks in advance

  • March 2, 2008 at 6:29 pm

    Hi Jan

    At this moment I’ve built the i-jetty app. I don’t know if I do this right, but now it’s occurring the following error (on the emulator) when I try to run the app:

    Application Error: org.mortbay.ijetty
    An Error has occured in org.mortbay.ijetty.java.lang.ExceptionInInitializeError.

    In the debug I could that this happens in this line of the IJetty.java, when I click on the Start button:
    startService(new Intent(IJetty.this, IJettyService.class), null);

    Do you know what’s going on?

    Thanks in advance!

  • March 2, 2008 at 11:29 pm

    Hi Luciano,

    I believe that I forgot to commit a couple of classes to svn. It should be all checked in now, so do an svn up, rebuild and try it again.


  • March 5, 2008 at 6:19 am

    1) how can i get the source code of i-jetty  in zip format.
    2) can i run web services on i-jetty

  • March 5, 2008 at 10:34 am

    i am getting 105 errors in i-jetty code what amy the problem be?

  • March 6, 2008 at 4:54 am

    how can i run JSP page on i-jetty?

  • March 6, 2008 at 9:26 pm

    JSP technology has not been ported to the mobile. JSP is a very file-based technology and most of the environment of android is not.  Moreover, the software architecture of android provides strict separation of visibility of data between applications.

    Having said that, android does support the use of an SD card, from which Jetty can already serve files. However, there’s a bit of a leap between that and making JSPs work, with their temporary directories, on-the-fly compilation etc etc.

    I’d be interested in hearing about what you’re doing with Jetty on android, as what folks need/want to do will help shape the future direction that i-jetty takes.


  • March 6, 2008 at 10:39 pm

    Hi Jan

    Well, we are interested on Android as a potential platform we would use in our academic work. So, we are testing what already is implemented. In fact, we need a implementation of a SOAP Server on Android, so I ask you if you intend to implement this feature. If not, maybe our team could help to meet this goal. I would appreciate if you contact me by email.

    Best regards

  • March 14, 2008 at 6:19 pm

    I am also getting the error
    Application Error: org.mortbay.ijetty
    An Error has occured in org.mortbay.ijetty.java.lang.ExceptionInInitializeError.

    I checked out a fresh version and still happening.

    It looks good

  • March 18, 2008 at 7:32 am

    Hi, great to see this happening. We have been developing a web server and related applications for S60 for a while now. I am curious to know how are you going to enable incoming traffic from the Internet? I mean how to get bypass changing IP and firewalls on the cellular network. Or do you plan to have it working only for localhost and a local LAN?

    In case you’re interested in our S60 web server (based on Apache) it’s available at http://mymobilesite.net, and there is a whole lot of developer stuff at http://forum.nokia.com/mws.

  • March 21, 2008 at 12:50 am


    if the mobile ISPs block access, then we will be restricted to localhost and phones that have wifi and/or bluetooth.   But for the main app that we are working on (manage contacts, images, etc from a browser), that is probably not a big limitation.

    If mobile ISPs are going to allow access to the phones, then I’d only expect limited ports like 80 to be available, so that means a HTTP server makes more sense.  But one would have to consider the application that would make the network costs worthwhile….   while a mobile phone may be a tempting ad-hoc webcam, I’d want that to use wifi rather than g3 🙂

  • March 25, 2008 at 2:07 am

    Hi Jan,
        recently, I have ported httpd to android recently. When I saw i-jetty, I guess it’s a better choice. After explored the code, I found jsp is not supported,
        Do you mean i-jetty can just support writing servlet?
        Do you have plan to support this?

    Thanks & Regards

  • March 25, 2008 at 2:15 am

    any way
    I have sucessfully run the i-jetty on simulator


  • March 27, 2008 at 3:13 am


    Support for jsps requires jvm support for dynamic class loading. The android platform at the time of writing does not support that. I’ve tried one of the workarounds that the osgi guys have been using to get the osgi bundles loaded, but I can’t seem to get it to work.

    I raised a bug for this at the Android issue tracker:

    As you can see, dynamic classloading will not be supported for 1.x. Not sure what the reasoning behind that is, but by all means raise a bug or otherwise let the Android devs know that you’re interested in such a feature and see if we can shift up the priority.


  • April 4, 2008 at 5:31 pm

    Hi Jan,

      Thanks your comments.

     If dynamic load is enable,

      Do you have some idea about how to make developer develop web application on android phone?

     And google the latest code seams enables the dynamic load. Even they disable the function later, we still have some ways to enable dynamic load java class. So we can develop some wars and download to android phone.

     And now i-jetty removed "start" part to deploye web application automaticly.

      We need give a pattern for developers to develop web application for android phone. Also need a delpoye tool like "start".

     Do you have any good advice?

     Any suggestion is welcome, thankx.




  • April 11, 2008 at 7:33 am

    Hi Huadong,

    Well, even if dynamic class loading is supported by the jvm, there’s still a way to go to make webapplication development easy.  For example, to support jsp on-the-fly compilation, the Dalvik jvm would need to support byte-code-generation, and as I understand it this is also missing.

    As that facility is missing, in order to support jsps, you’d need to precompile them, and precompile them for the Dalvik jvm.  So you’d need to mess around with generating the java code using jspc, then run the Dalvik compiler on the generated files. So that just makes webapp dev that bit more difficult.

    Leaving aside jsps, and the need to compile your whole webapp with the Dalvik compiler, there’s still the issue that there’s no way of sharing libraries on the Dalvik platform. So, for example, it would be convenient if you could use the published jetty libs from the i-jetty project rather than having to import the sources into your project and build them.

    In the short term, if you want to do webapp development, I’d stay away from jsps, selectively import the jetty sources into your webapp project, and then write a little class with a main to start a jetty server and deploy your webapp (some examples are in the examples/embedded directory of the jetty distro).

    If the future, I’d like to write a jetty deployer that would be able to load an Android .apk bundle that contains a webapp from say the sdcard.


  • April 15, 2008 at 8:42 am

    Hi Jan,
        agree, support jsp is a little more difficulty.

        I got one way to develop web application for i-jetty on android by using
        Developer uses eclipse + maven + jetty-maven-plugin to develop web application and servlet. They need make sure the dependence on jetty6.1.9.
        all the servlet will be compiled into a jar file, use dex tool convert the jar file to dex, then zip it as a jar. we can even make the process automatic.
        when make package for web application, put the above servlet jar into webapps’s lib dir. After package, we get a WAR file. This file can be installed to android internal web server webapps dir.
         During xmlConfiguration configure the web application, I add a class name MyClassLoader to load those servlet.

    MyClassLoader is derived from URLClassLoader and it uses dexFile to open the jar, use WabAppClassLoader as parent classloader.


  • June 18, 2008 at 3:32 pm

    Hi Jan,

    I tried downloading i-jetty by  an svn checkout of the source.
    http://i-jetty.googlecode.com/svn/trunk/ i-jetty-read-only

    However when I gave this url, eclipse threw me an error saying that the remote location did not exist. But after several attempts the following url worked http://i-jetty.googlecode.com/svn/trunk.

    Now I am able to run i-jetty on the emulator device. But when I try to acess i-jetty from my machine browser http://localhost:8080 (after doing the adb forward) I get the following error.

    <font size=”2″>

    ERROR/Jetty(664): EXCEPTION

    ERROR/Jetty(664): java.lang.ExceptionInInitializerError: org/mortbay/jetty/Response

    ERROR/Jetty(664): at org.mortbay.jetty.HttpConnection.<init>(HttpConnection.java:116)

    ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:328)

    ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector$1.newConnection(SelectChannelConnector.java:103)

    ERROR/Jetty(664): at org.mortbay.io.nio.SelectChannelEndPoint.<init>(SelectChannelEndPoint.java:51)

    ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector$ConnectorEndPoint.<init>(SelectChannelConnector.java:338)

    ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:322)

    ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector$1.newEndPoint(SelectChannelConnector.java:108)

    ERROR/Jetty(664): at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:533)

    ERROR/Jetty(664): at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:166)

    ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)

    ERROR/Jetty(664): at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:537)

    ERROR/Jetty(664): at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

    My laptop has windows vista.

    Could you please guide me as of what the problem might be?




  • July 24, 2008 at 4:06 am

    Hi Jan

    Brilliant work with i-jetty. I had an early release working on OS X. Now I’m using the latest release (revision 91) on Ubuntu 8.04 and having a few problems.

    Running   deploy.sh   seems to build and install everything correctly. i-jetty starts in the emulator.

    But then accessing; from outside the emulator, or &nbsp; from the browser inside the emulator gives

    Error 404 – Not Found.
    No context on this server matched or handled this request.
    Contexts known to this server are:

    I get the same result by ‘hand-crafting’ the build/install.

    So it looks like i-jetty is doing something, but not picking up the Hello and Console webapps that should have been deployed.

    Perhaps the sdcard content isn’t what it should be. The content after running deploy.sh is at the end of this message.

    It’s probably something trivial but I’ve spent 2 full days trying to solve this problem with no success. I wonder if you can suggest anything?

    (BTW I’m intending to use i-jetty for a port of our open-source Greenstone 3 digital library software… http://www.greenstone.org)



    contexts  etc  webapps



    console  hello

    console.css  index.html  meta-inf  web-inf

    manifest.mf  maven



    pom.properties  pom.xml

    classes  web.xml


    index.html  meta-inf  web-inf

    manifest.mf  maven



    pom.properties  pom.xml

    classes  libs  web.xml



  • July 25, 2008 at 12:21 am

    Hi Steve,

    Thanks for the interest in i-jetty! We’ve been doing some major reorganizations on it lately, and I think you have caught us mid-stream.

     We changed the console from being anchored at "/" to "/console" so I would expect you to get the default jetty 404 page listing the contexts available. I’d be conconcerned if http://localhost:8888/console was not available – is it?  I do plan to provide a much nicer looking default 404 page when running jetty under android, but I unfortunately I just haven’t managed to get around to it yet 🙁

    You should be able to avoid that page if you deploy a webapp at "/" – either by putting it in webapps/ROOT  or by using a context xml file to explicitly set the  context path to "/".


  • July 25, 2008 at 5:40 am

    Hi Jan

    Thanks for the quick response. Good news….

    A clean install and build of r91 worked perfectly (webapps are available and working) after

    1. mvn install     (complains that no path to android home)
    2. mvn -Dandroid.home=<PATH_TO_ANDROID> install
    3. ./deploy.sh

    But I then attempted to repeat the process… delete i-jetty, check it out again, same steps as above… and was back at the same state as in my previous post.   ie i-jetty apparently working but the webapps don’t appear.

    The only difference between non-working and working states was a reboot in between. So I rebooted and the problem was resolved. I am now unable to replicate the problem at all.

    Therefore it must have been something about my machine’s state (Ubuntu 8.04 inside VirtualBox on OSX 10.5.4).

    My apologies for taking up your time with the problem.  If I _can_ replicate it I’ll let you know.

    Thanks again.

  • November 19, 2008 at 7:21 am

    Hello Jan,
    I have a J2me project in NetBeans, I want to run it on android.
    I have tried through J2me Midp runner but it didnt work. Can you plz tell me is there any way to convert my jar file to .apk through command line.
    Sudha Gupta

  • January 26, 2009 at 11:16 am


  • January 27, 2009 at 10:13 am

    Hi Alberto,
    The war files need to be served from a web server, and then downloaded by the ijetty application. The easiest way to download them is type into the ijetty download application the url of the webapp from the ijetty download page on google.
    By the way, the best way to discuss i-jetty is via the jetty mailing list at support@jetty.codehaus.org.

  • January 28, 2009 at 5:04 pm

    Oh, ok, thank you Jan.
    So, for example, if I’m developing a webapp, how should I download it or make it work in the IJetty?
    Should I put it into a web server? can it be a local server? or can I do just adb push into the correct path in the IJetty?
    Thanks a lot for your help. And thank you for telling me about the jetty mailing list.

  • January 28, 2009 at 8:14 pm

    Thank you again Jan!
    I’ve already downloaded both example apps, although when I’m trying to find them in the browser, their links appear in the localhost:8080 page, but when I’m trying to find them in their own path by clicking the links or writting the path, they don’t appear, it says error 503, service unavailable.
    Anyway, thank your for your help!

  • February 3, 2009 at 3:57 pm

    I have the same problem as alberto – HTTP ERROR: 503. How do I setup the permission?

  • February 11, 2009 at 7:03 am

    hello jan i am Lakhdar i have probleme with i-jetty i installed it in emulator under windows and when i acced to my broser “internet explorer”on my desktop and i tpe”″no thing displayed could not find page i do not know what is the problem?!thanks advance and accept all my respects.please answer me i wait u

  • February 12, 2009 at 8:51 pm

    Hi Jan

    Re: ijetty webapps, external library class property files and Resource Bundles

    I’m making progress turning our Greenstone software http://www.greenstone.org/greenstone3-home into an i-jetty web. However it’s dependent upon external packages such as xalan etc which have class .properties files that the packages attempt to load a runtime.

    An example runtime error is (within Xalan org.apache.xml.serializer)

     ToXMLSAXHandler: MissingResourceException ToXMLSAXHandler: classname = org.apache.xerces.impl.msg.DOMMessages_en_US 

    Dexing my webapp ignores .properties files. They end up in the web-inf/classes directory. –keep-classes makes no difference.

    I can hack around this for the Greenstone code but not the external libraries.

    Do you have any advice for i-jetty webapps using external packages that load properties as ResourceBundles?

    Cheers, Steve

  • February 26, 2009 at 10:46 am

    hi everybody my problem is what u mean by context path?and how can i choose it?thank u very much advance.accept my all respects.good day

  • April 19, 2009 at 5:33 am

    Hi Steve,
    The good news is that I think sdk1.5_pre seems to solve the ResourceBundle problem. I’ve only done a quick preliminary test, but the signs are good so far!

  • April 26, 2009 at 2:07 am

    Hi, I am using ijetty2.0 with sdk1.1-r1 and I download the source code ,mvn,and python as the instructions said but I want to know from where I have to run the code on my g1 and how. Moreover, I followed the instruction to install the mvn but there is error field to install it .
    Would you please tell me what exactly the role of each tool I have dowwnload it as I said above on this project??

  • May 3, 2009 at 5:55 pm

    Hello Jan,

    I wanted to say thanks for porting Jetty to the Android platform. I am doing research on Parallel Mobile applications at the University of San Francisco. We are thinking about using Jetty as part of our project.

    I have had a little trouble getting the hello and chat apps to run (getting a 503 error), so I posted issue #45 on code.google.com.

    thanks again,

  • May 4, 2009 at 12:53 am

    Hi Jer,

    I’ve responded on your issue. Just wanted to say good luck with the project, and please let me know how it goes! I’d be happy to put up anything that comes out of the project on the Jetty Powered pages

    cheers, Jan

  • July 15, 2009 at 2:44 pm

    Hi. I

  • July 18, 2009 at 6:38 pm

    Hi Jan:
    I’m able to successfully install the Hello.war servlet from within Ijetty, however when I go to and select the context for the Hello app from the list that appears after the 404 error, the resulting page say Http error 503, problem accessing Hello2.0, reaason: Service Unavailable.
    Also wondered if Webdav servlet has ever been successfully run within Ijetty?
    Thanks much for any help.

  • April 2, 2010 at 10:23 pm

    I am configuring the greenstone 3.04 to a fedora 12 server. everything is running perfectly except when i modify a collection from the applet version (client machine) then the error “Sh: db2txt command not found” comes and the error comes in xml plugins .so the metadata is no build , But it shows that collection build successfully. but when i go to the search page it shows none and the gsdl server crashed.
    Plz reply soon if you can help me out.

  • April 6, 2010 at 2:09 am

    Hi Anirban,

    I think you’ll have to contact the Greenstone project folks
    for this one, as the error you report doesn’t seem to describe
    a problem in the i-jetty code. If the Greenstone folks find an
    i-jetty problem, please do ask them to raise an issue at http://code.google.com/p/i-jetty/issues/list.



Comments are closed.