Building Simple HTML Server Using JavaFX & Undertow

I recently had a customer who wants to view swagger-ui documentation for his APIs but he didn’t know how to set up a server and he wants to run in on his own laptop, not hosting anywhere else. With developers like us, there is no problem setting up a quick docker project and view the content. However, installing Docker is quite a lot for a non-tech user.

So, I decided to create a small JavaFX application that can run right away (given that the customer has JRE installed or can download and install quickly).

Application source code

You can download the source code from github and try yourself here:

After that, you can simply run the Launcher file to have the server running.

How to use the application

When you launch the application, a small window appears like this:

Simple http server

There isn’t much thing to do, simply select the folder to be the web root and the port you want to run and click on start server.

If I visit the link http://localhost:9988 in my browser, this is what I see:

And you can easily navigate through the files.

One nice thing is you can use this to serve your videos (*.mp4) and watch on your phone (by accessing via your computer’s IP).

Leave a Comment