Week 63 — What is the `jwebserver` tool?
Question of the Week #63
What is the
jwebserver tool?1 Reply
Recent JDKs include a tool named
jwebserver which is a simple HTTP server serving static files.
It is possible to start it by entering the command jwebserver which then serves files in the current directory.
By default, it uses port 8000 on the loopback interface (i.e. it only allows local connections).
It is possible to change that behavior using command-line arguments. It's possible to change the address to listen to using -b, the directory to serve using -b and the port using -p.
For example, the following command can be used to serve /tmp/someDirectory on all network interfaces using port 8080:
This tool is mainly for testing/getting an HTTP server for development.
The JDK also provides an API for using it programmatically in the package com.sun.net.httpserver:
📖 Sample answer from dan1st