Java Mini Web Server
A small web server, less than 4kb in size!
Download SimpleWebServer.jar (4kb)
This is a very small standalone web server written in Java. It is packaged in a jar file and may also be used within your own Java programs.
How big is the program?
The entire program is less than 4kb in size. To be precise, it is 4095 bytes (4kb is 4096 bytes). This HTML page is much larger! :)
Starting the Web Server (standalone mode)
The web server is packaged in a single small jar file for ease of use. You will need Java runtime version 1.2 or later installed in order to execute the web server.
To execute the web server, issue the following command: -
java -jar SimpleWebServer.jar
This will start the web server on the default port (80) and your web root directory will be the current directory. You should now be able to request web pages from the web server with your web browser.
Note that you must have installed a Java Runtime Environment in order to run Java programs. Please read this guide on How to set up Java if you need help.
Java HTTP Web Server Library
The package may also be used as a Java HTTP Web Server Library.
Simply add the jar file to your classpath and import
org.jibble.simplewebserver.*;. You can then construct
a new SimpleWebServer object by supplying two arguments to its
SimpleWebServer server = new SimpleWebServer(new File("./"), 80);
This starts up the web server within your program so that users may request web pages.
Java Web Server Features
Considering the fact that this very small web server is less than 4kb in size, it still has a fair few useful features:-
- Very small executable.
- Can deal with multiple requests at the same time.
- Support for a small variety of content-types (images, HTML, text, etc).
- Directory browsing features.
- Index page retrieval without specifying full path.
To keep the web server small, only the optimized compiled code is contained in the jar file. The source code is included in this version: SimpleWebServerFull.jar
This software product is OSI Certified Open Source Software, available under the GNU General Public License (GPL). Since the GPL may be too restrictive for use in proprietary applications, a commercial license is also provided.
Purchase a commercial license for this software.
Search this site
Copyright Paul Mutton 2001-2010