Tuesday, February 23, 2010

A Tiny Web Server for R&D or Local File Share


Very tiny, it really is. Taking advantages of Java's existing libraries, its size is: 4095 bytes. Yes, it is BYTES. Not Kilobytes. I am wondering whether it is possible to implement a smaller one without using assembly.

- On Windows, if filename extension is associated properly, you can double-click it in Explorer and get it up and running.

- On Linux, you need to use java -jar SimpleWebServer.jar.

The root dir is the directory you started it with. All interfaces are listened. Port 80 is used.

As a supplement, on Debian derivatives (including Ubuntu), you need to add sudo to make it possible to bind to TCP port 80. Otherwise you will suffer from permission problems.

No comments: