Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Nimble code reloading for Java servlets
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


JShotgun (view source) is an auto reloading Java servlet. It can be used as a simple alternative to the complex reloading logic that is provided by some web frameworks.

JShotgun loads your application in a temporary class loader. It then watches any classes loaded from local files. If a class file is changed on disk it reloads the entire application. Classes loaded from jar files are excluded so only application code is reloaded. This also means that JShotgun automatically becomes a noop in most production environments.

You will need a method of automating the compilation. That could be anything from Eclipse's "Project Menu -> Build Automatically" option to a simple shell script:

while true; do inotifywait *.java; javac *.java; done

Requires Java 7 and is fastest on operating systems with native WatchService support (Linux and Solaris). Reloads immediately in the background so most of the time there's no noticeable delay at all.

Concurrency safe: waits for any outstanding requests to be completed before reloading.


JShoting is normally configured in your web.xml file. Set the init-param to the classname of the HttpServlet to be wrapped. Here are some examples with different web frameworks.

JShotgun with Spring


JShotgun with RESTEasy JAX-RS


Getting it

JShotgun is available from the Clojars Maven repository (raw jar files).

Some day I'll get around to pushing it to Central. For now you'll need to add the Clojars repository:


Add this dependency to your pom.xml:


See also

  • Shotgun - the Ruby library that inspired JShotgun
  • Spring Loaded - a more sophisticated reloader that uses a JVM agent


The MIT License (MIT) Copyright (c) 2013 Alex Osborne

Something went wrong with that request. Please try again.