Jetty Web server can be invoked and installed as a stand alone application server. It has a flexible component based architecture that allows it to be easily deployed and integrated in a diverse range of instances. The project is supported by a growing community and a team with a history of being responsive to innovations and changing requirements. More info here.
First you need to download Jetty. It’s distributed as a platform independent zip file containing source, javadocs and binaries. The most recent distro can be downloaded from Codehaus:
$ wget http://dist.codehaus.org/jetty/jetty-6.1.14/jetty-6.1.14.zip
$ unzip jetty-6.1.14.zip
$ cp -R jetty-6.1.14 /opt/
$ cd /opt
$ ln -s /opt/jetty-6.1.14 jetty
Problems installing Jetty? More info here.
Running jetty is as simple as going to your jetty installation directory and typing:
$ cd /opt/jetty
$ java -jar start.jar etc/jetty.xml
This will start jetty and deploy a demo application available at:
That’s it. Now stop Jetty with cntrl-c in the same terminal window as you started it.
Quercus is a complete implementation of the PHP language and libraries in Java. It gives both Java and PHP developers a fast, safe, and powerful alternative to the standard PHP interpreter. Quercus is available for download as a WAR file which can be easily deployed on Jetty:
$ wget -P ~/quercus http://quercus.caucho.com/download/quercus-3.2.1.war
$ jar xf ~/quercus/quercus-3.2.1.war
Unpack the WAR file and copy all the jars to Jetty’s global library directory:
$ cp ~/quercus/WEB-INF/lib/* /opt/jetty/lib
Edit the web.xml file:
$ vi /opt/jetty/webapps/test/WEB-INF/web.xml
Add the following between the web-app tags:
Create a PHP file inside the test application:
$ cat /opt/jetty/webapps/test/index.php
<?php phpinfo(); ?>
This file will be available at:
It works! You are now ready to:
Instantiate objects by class name
$a = new Java("java.util.Date", 123);
$a = new Date(123);
Call Java methods
$a = new Date(123);
$a->time = 456;
And much, much more.