How do I use the simple web server that comes with Jini?

Tim Rohaly

Because most Jini services need to make their .class files available via HTTP for dynamic downloading, Jini bundles a simple web server for your convenience. You don't have to use this web server - you can always use a full-blown server like Apache to serve up your .class files. However, full-blown web servers are overkill for many Jini applications.

The web server provided with Jini is quite limited - it will only serve .class files - it will not serve .html, .gif, or any other type. It is implemented by the class com.sun.jini.tool.ClassServer; the source code can be found in the /source/vob/tools/src/com/sun/jini/tool directory underneath the Jini install directory, while the class files are in tools.jar, found in the /lib directory. The web server can be run from the /lib directory using the following command line:

java -jar tools.jar [-dir <dir>] [-port <port>] [-stop] [-trees] [-verbose]
The options, and their default values, are:
-dir <dir>    Specifies the root directory for the web server
              Defaults to "J:" on Windows
              Defaults to /vob/jive/jars on non-Windows OS

-port <port>  the port number to listen on.
              Defaults to port 8080.

-stop         Gracefully shut down a running server instance

-trees        Search all .jar files in document root to find .class file.
              For instance, if you started the ClassServer with the root
              directory set to the location of tools.jar, then retreiving the
              bytecode com.sun.jini.tool.ClassServer.class would be done through
              the relative URL of /tools/com/sun/jini/tool/ClassServer.class
              (/tools specifies tools.jar in the root directory, and
              /com/sun/jini/tool/ClassServer.class specifies fully-qualified name
              of ClassServer.class within that .jar).

-verbose      Logs requests to standard output