Run/Distribute Java Webapps via a Single Jar File

Tomcat is a very light weight Servlet container. In contrast to a typical development scenario in which we deploy your Java web applications on a standalone Tomcat instance, we can also integrate the server runtime directly within our applications, resulting in some interesting, convenient ways of using Tomcat.

In the sample application that I built, I made use of Apache Tomcat Maven Plugin. The Tomcat Maven Plugin provides goals to manipulate WAR projects within the Apache Tomcat servlet container. On the other hand, it also allows us to run war project with an embedded Apache Tomcat. The run goals gives us the opportunity to quickly develop applications without needing to install a standalone Tomcat instance.

Tomcat meme

Moreover, this feature adds to the beauty wherein a web application can be easily distributed and can be run through a jar file only, no server setup and deployment needed.

I have used the version 2.0 of tomcat7-maven-plugin, but I would highly recommend to go for Version 2.3-SNAPSHOT of this plugin. Let me beware you, the version 2.2 has some serious bugs which will make your time and effort go waste, or lets say it will make your effort more than what’s really needed.


I also created a batch file, which I used to trigger the jar file. The batch file code is as follows, which basically aims to start the jar file and launch the internet explorer with the web app url.

@echo off
echo Refresh the page once configuration is up...
echo Application is accessible at http://localhost:8080
start iexplore http://localhost:8080
java -jar "jceutil_standalone.jar"
cmd.exe /K

Find the code of my entire project at my github repo: