Need help with spring-boot-thin-launcher?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

560 Stars 74 Forks Apache License 2.0 455 Commits 18 Opened issues


Tools for building "thin" executable jars, with a focus on, but not exclusively for, Spring Boot

Services available


Need anything else?

Contributors list

Spring Boot Thin Launcher

A "thin" jar launcher for java apps. Version 1.0.28.RELEASE is in Maven Central, snapshots are in See for more discussion and ideas.

Getting Started

The thin-launcher provides its own custom layout for the Spring Boot plugins. If this layout is used then the jar built by Spring Boot will be executable and thin.

NOTE: if you are using a snapshot version of the thin launcher you either need to build it locally or include the snapshot repository declarations. You can use to find suitable repository declarations for Maven and Gradle, or look at the samples in this project.

With Maven, build a Spring Boot application and add the layout. This means adding it to the Spring Boot plugin declaration:


and in Gradle, you can use the older

style declaration:
buildscript {
    ext {
        springBootVersion = '2.2.4.RELEASE'
        wrapperVersion = '1.0.28.RELEASE'
    repositories {
    dependencies {
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot.experimental.thin-launcher'

publishing { publications { maven(MavenPublication) { from } } }

Or you can use the newer

style declaration:
plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id 'maven-publish'
    id 'org.springframework.boot.experimental.thin-launcher' version '1.0.28.RELEASE'

group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8'

repositories { mavenLocal() mavenCentral() maven { url "" } maven { url "" } }

publishing { publications { maven(MavenPublication) { from } } }

For Spring Boot 2.x snapshot versions (or older releases) you also need a

with the repository configuration for the plugin. e.g. (as generated by
            if ('org.springframework.boot.experimental.thin-launcher'){

If you don't need snapshots you can leave it all out and rely on the defaults. If you are testing a change you made to the plugin you might want to put

in the
as well.

In Gradle you also need to generate a

or a
(unless you want to maintain it by hand). A
will be generated automatically by the "thinPom" task in the Thin Gradle plugin. It does this by calling out to the maven plugin and the dependency management plugin; the maven plugin is always present, and the dependency management plugin is present if you are using the Spring Boot plugin. To generate a
remember to apply the maven and Thin Gradle plugins.

NOTE: Gradle now has a

plugin that works with the newer "standard" configurations (e.g.
). It also works with the thin launcher plugin.

The generated pom goes in the normal maven place by default under

. You can configure the output directory by setting the "output" property of the "thinPom" task.

You can customize the generated

, or switch it off, by creating your own task in
and forcing the jar task to depend on it instead of "thinPom", or by simply not using the Thin Gradle plugin. Example (which just duplicates the default):
task createPom {
    doLast {
        pom {

jar.dependsOn = [createPom]

Instead of or as well as a

you could generate a
gradle thinProperties
(the task is always registered by the Thin Gradle plugin but is not executed by default). By default it shows up in
in the built resources, so you need to run it before the jar is built, either manually, or via a task dependency, e.g.
jar.dependsOn = [thinProperties]

The generated properties file is "computed" (it contains all the transitive dependencies), so if you have that, the dependencies from the

will be ignored.

If you look at the jar file produced by the build you will see that it is "thin" (a few KB), but executable with

java -jar ...

How does it Work?

Inspect the app jar that you built (or one of the samples in this project) and notice that it is only a few KB. It is just a regular jar file with the app classes in it and one or two extra features. The things it needs to operate are:

  1. The
    class has been added.
  2. Either a
    and/or a
    which lists the dependencies of the app.

When the app runs the main method per the manifest is the

. Its job is to locate another jar file (the "launcher"). The wrapper downloads the launcher (if it needs to), or else uses the cached version in your local Maven repository.

The launcher then takes over and reads the

(if present) and the
, downloading the dependencies (and all transitives) as necessary, and setting up a new class loader with them all on the classpath. It then runs the application's own main method with that class loader. The
can be in the root of the jar or in the standard

The app jar in the demo is built using the Spring Boot plugin and a custom

(so it only builds with Spring Boot 2.x and above).

Caching JARs

All jar files are cached in the local Maven repository, so if you are building and running the same app repeatedly, it should be faster after the first time, or if the local repo is already warm.

The local repository can be re-located by setting a System property "thin.root". For example to use the current directory:

$ java -Dthin.root=. -jar app/target/*.jar

This will download all the dependencies to

, and look for Maven settings in

You can also do a "dry run", just to warm up the cache and not run the app, by setting a System property or command line argument "thin.dryrun" (to any value except "false"). In fact, since you don't need the application code for this (except the

), you could run only the launcher, or the wrapper which is contained in the launcher for convenience. This is a useful trick for laying down a file system layer in a container image, for example.

NOTE: options for the

that are listed as
can also be provided as command line arguments (
per Spring Boot conventions), or as environment variables (
capitalized and underscored). The command line options are removed before passing down to the Boot app. The
also accepts system properties, environment variables or command line flags for its (smaller) set of optional arguments.

Build Tools


In addition to the Spring Boot layout there is an optional Maven plugin which can be used to do the dry run (download and cache the dependencies) for the current project, or for any project that has an executable thin jar in the same format. The "app" sample in this repo declares this plugin and inserts it into the "package" lifecycle:


After running the build, there is a deployable warm-cache and a copy of the executable jar at

(by default):
$ cd samples/app
$ mvn package
$ cd target/thin/root
$ java -Dthin.root=. -jar app-0.0.1-SNAPSHOT.jar

The "simple" sample has the same feature, but it also downloads and warms up the cache for the "app" sample, so you could use the same build to run both apps if you felt like it.

The Maven plugin also has a

mojo, so you can create or update
from the dependencies of the project directly. By default it creates a
, but you can change the output directory with the plugin configuration. Example:
$ cd samples/app
$ mvn spring-boot-thin:properties -Dthin.output=.

By default the
is "computed" (i.e. it contains all transitive dependencies), but you can switch to just the declared dependencies using the "compute" configuration flag in the plugin (or
on the command line).


The same features are available to Gradle users by adding a plugin:

buildscript {
    dependencies {

... apply plugin: 'org.springframework.boot.experimental.thin-launcher'

The plugin creates 2 tasks for every jar task in the project, one that reolves the dependencies, and one that copies the jar into the same location to make it easy to launch. A "dry run" can be executed in Gradle by calling the "thinResolve" task defined by the plugin, e.g.

$ cd samples/simple
$ gradle thinResolve
$ cd build/thin/deploy
$ java -Dthin.root=. -jar simple-0.0.1-SNAPSHOT.jar

The default location for the cache is

but this was changed in the
for that sample:
thinResolvePrepare {
    into new File("${buildDir}/thin/deploy")

NOTE: The "thinResolve" and "thinResolvePrepare" tasks are the default names for a single jar project. If your jar task is not called "jar", then the names are appended with the jar task name (capitalized), e.g. "thinResolveMyJar" for a task called "myJar"). If you have multiple jar tasks in the project, then each one has its own resolve tasks.

Deploying to Cloud Foundry (or Heroku)

The thin launcher (1.0.4 and above) adds an empty "lib" entry to the jar so that it matches the default detection algorithm for a Java application with the standard Java buildpack. As of version v4.12 of the Java buildpack the dependencies will be computed during staging (in the "compile" step of the buildpack), so you don't incur that cost on startup.

You can also save the staging cost, and resolve the dependencies locally before you push the app.

$ java -jar target/demo-0.0.1.jar --thin.dryrun --thin.root=target/thin/.m2
$ (cd target/thin; jar -xf ../demo-0.0.1,jar)
$ cf push myapp -p target/thin

(Note the use of a subdirectory

to hold the local repository cache - this works because the root is the default
directory in a Cloud Foundry app.)

The Maven plugin has a "resolve" task with a flag unpack (or

on the command line) that creates the cache in the precise form that you need to push to Cloud Foundry. The unpack flag is false by default, so remember to set it if you want to use Maven to prepare the push.

Command Line Options

You can set a variety of options on the command line or with system properties (

). The
properties are all removed from the command line before calling the main class, so the main class doesn't have to know how it was launched.

| Option | Default | Description | | ------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |

| Start-Class in MANIFEST.MF | The main class to launch (for a Spring Boot app, usually the one with
) | |
| false | Only resolve and download the dependencies. Don't run any main class. N.B. any value other than "false" (even empty) is true. | |
| false | Switch to "offline" mode. All dependencies must be available locally (e.g. via a previous dry run) or there will be an exception. | |
| false | Force dependency resolution to happen, even if dependencies have been computed, and marked as "computed" in
. | |
| false | Only print the classpath. Don't run the main class. Two formats are supported: "path" and "properties". For backwards compatibility "true" or empty are equivalent to "path". | |
| The location of the local jar cache, laid out as a maven repository. The launcher creates a new directory here called "repository" if it doesn't exist. | |
| the same as the target archive | The archive to launch. Can be used to launch a JAR file that was build with a different version of the thin launcher, for instance, or a fat jar built by Spring Boot without the thin launcher. | |
                                                                        | A parent archive to use for dependency management and common classpath entries. If you run two apps with the same parent, they will have a classpath that is the same, reading from left to right, until they actually differ.                                       |
| The path to directory containing thin properties files (as per
), as a comma-separated list of resource locations (directories). These locations plus the same paths relative /META-INF will be searched. | |
| "thin" | The name of the properties file to search for dependency specifications and overrides. | |
| | Comma-separated list of profiles to use to locate thin properties. E.g. if
the launcher searches for files called
. | |
| A locator for the launcher library. Can be Maven coordinates (with optional
prefix), or a file (with optional
prefix). | |
(also contains GA releases) | Base URL for the
if it is in Maven form (the default). | |
| The main class in the
. If not specified it is discovered from the manifest
attribute. | |
| true | Flag to say that the class loader is "parent first" (i.e. the system class loader will be used as the default). This is the "standard" JDK class loader strategy. Setting it to false is similar to what is normally used in web containers and application servers. | |
| true | Flag to say that the parent class loader should be the boot class loader not the "system" class loader. The boot loader normally includes the JDK classes, but not the target archive, nor any agent jars added on the command line. | |
| false | Flag to switch on some slightly verbose logging during the dependency resolution. Can also be switched on with
(like in Spring Boot). | |
| false | Super verbose logging of all activity during the dependency resolution and launch process. Can also be switched on with
. |

Any other*
properties are used by the launcher to override or supplement the ones from
, so you can add additional individual dependencies on the command line using*
(for instance).

Downstream Tools

The default behaviour of the

is to locate and launch the
, but it can also run any main class you like by using the
properties. One of the main reasons to provide this feature is to be able to support "tools" that process the application jar (or whatever), for example to generate metadata, create file system layers, etc. To create a new tool, make an executable jar (it can even be thin) with a
in its manifest, and point to it with
. The launched main class will find the same command line as the launched jar, but with
removed if it was there. It will also find a system property
containing the location of the launched jar, or the original
if that was provided on the command line (this is the archive that contains the data to process normally). If the tool jar is thin, i.e. if the main class is
, then the
command line argument and system property will also be removed (to prevent an infinite loop, where the wrapper just runs itself over and over).

An example of a tool jar is the

(see below). You could use that as a prototype if you wanted to create your own.

HOWTO Guides

How to Externalize the Properties File

Example command line showing to pick up an external properties file:

$ cat config/
dependencies.spring-boot-starter-web: org.springframework.boot:spring-boot-starter-web
$ java -jar app.jar --thin.location=file:./config

How to Create a Docker File System Layer

Precompute the dependencies:

$ java -jar app.jar --thin.root=m2 --thin.dryrun
$ java -jar app.jar --thin.classpath=properties >

Then build a docker image using a

based on this:
FROM openjdk:8-jdk-alpine

ADD m2 m2 ADD app.jar app.jar ADD

ENTRYPOINT [ "sh", "-c", "java -jar app.jar --thin.root=/m2" ]


The step to add a
is optional, as is its calculation (you could maintain a hand-written properties file inside the JAR as well).

How to Change Dependencies

You can change the runtime dependencies, by changing the
in the jar. You can also read a local
from the current working directory, or set a System property
to change the local file name (defaults to
). There is also a
(comma separated list) which is appended to
, so additional libraries can be added using
. Profile-specific properties are loaded last so they take precedence. Example to pick up an extra set of dependencies in
$ java -jar myapp.jar --thin.profile=rabbit

can be saved in the jar file (conventionally in
), or in the current working directory by default.

NOTE: You can add or override
entries on the command line or with System properties using key names in*
(the prefix
is stripped).

How to Upgrade Spring Boot or Spring Cloud

If your main pom (or properties) file uses boms to manage dependency versions, you can change the version of the bom using
. E.g.

If your main pom uses properties to manage dependencies (e.g. via the Spring Boot starter parent), you can change the value of the property using
. E.g.

where the pom has


How to Exclude a Transitive Dependency

You can exclude and remove dependencies by prepending a key in the properties file with

. E.g.

How to Convert a Thin Jar to a Fat Jar

There is a converter tool that you can use as a library in place of the launcher. It works by copying all of the libraries from a

into the new jar. Example:
$ java -jar myapp.jar --thin.dryrun --thin.root=target/thin/root
$ java -jar myapp.jar --thin.library=org.springframework.boot.experimental:spring-boot-thin-tools-converter:1.0.28.RELEASE
$ java -jar myapp-exec.jar


To build this project locally, use the maven wrapper in the top level

$ ./mvnw clean install

Then run the "app" jar:

$ java -jar ./app/target/*.jar

(It starts an empty Spring Boot app with Tomcat.)

You can also build the samples independently.

Classpath Computation

The launcher has some optional arguments that result in classpath computations, instead of running the Boot app. E.g.

$ java -jar myapp.jar --thin.classpath=path

prints out (on stdout) a class path in the form that can be used directly in

java -cp
. So this is a way to run the app from its main method (which is faster than using the launcher):
$ CLASSPATH=`java -jar myapp.jar --thin.classpath=path`
$ java -cp "$CLASSPATH:myapp.jar" demo.MyApplication

You can also compute the classpath using explicit name and profile parameters:

$ java -jar myapp.jar --thin.classpath=path --thin.profile=dev

will look for
to list the dependencies.

You can also specify a "parent" archive which is used to calculate a prefix for the classpath. Two apps that share a parent then have the same prefix, and can share classes using

. For example:
$ CP1=`java -jar myapp.jar --thin.classpath=path`
$ CP2=`java -jar otherapp.jar --thin.classpath=path --thin.parent=myapp.jar`

$ java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:off
-noverify -cp $CP1:myapp.jar demo.MyApplication $ java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:dump
-XX:SharedArchiveFile=app.jsa -XX:SharedClassListFile=app.classlist
-noverify -cp $CP1

$ java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:on
-XX:SharedArchiveFile=app.jsa -noverify -cp $CP1:myapp.jar demo.MyApplication $ java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:on
-XX:SharedArchiveFile=app.jsa -noverify -cp $CP1:otherapp.jar demo.OtherApplication

the two apps at the end are sharing class data from

and will also start up faster (e.g. 6s startup goes down to 4s for a vanilla Eureka Server).

The thin launcher can be used to pre-compute its own dependency graph in the form of a properties file, which also speeds up the launch a bit, even if you still have to resolve all the jars (remotely or from the cache). To compute the dependency graph and output the result in the form of a properties file, just use the

flag on startup, e.g.
$ java -jar myapp.jar --thin.classpath=properties >
$ java -jar myapp.jar

In this example the second startup will be slightly faster, depending on the size of the classpath, but up to a few hundred milliseconds on even a fast server, and more in a constrained environment.

It also works fine with profiles, so, for example, if

contains a
you could do this:
$ java -jar myapp.jar --thin.profile=rapid --thin.classpath=properties >
$ java -jar myapp.jar --thin.profile=super

Note that the generated
in these examples contains the property value
. This tells the dependency graph calculator that the dependencies provided do not need to have their transitive dependencies or versions computed. It is possible to combine more than one properties file if they have different values of the
flag, but if they both also contain dependencies then only the computed ones will be used. Note that this means you can compute a profile using
and use it as a cache, speeding up startup without affecting any other settings that might be in other

How to Change the Maven Local Repository

You can change the location of the local Maven repository, used to resolve and cache artifacts, using the standard Maven

file (with a top level element called
). You can
also use a system property 
which defaults to
) when you launch the thin jar, but not a command line flag. The Maven and Gradle plugins respond to the
and also (with Maven) to
as a command line flag.

How to Configure a Proxy

The dependency resolution uses Maven libraries, and should respect the proxy settings in your

. The initial download of the launcher by the
uses regular JDK libraries so you need to specify the normal
args for networking as well, unless you have the launcher already cached locally.

Using a Mirror for Maven Central

The thin launcher itself parses your local Maven

and uses the mirror settings there. To download the launcher itself, and bootstrap the process, you need to explicitly provide a
to the wrapper (the same as the mirror). You can do this on the command line when running the jar, using all the usual mechanisms. To run the build plugins
goals you can make the thin launcher jar a dependency of the plugin, to ensure it is cached locally before the plugin runs. E.g.

Or else you can set a project, system property or environment variable. E.g.

$ ./mvnw spring-boot-thin:resolve -Dthin.repo=http://localhost:8081/repository/maven-central


$ ./gradlew thinResolve -P thin.repo=http://localhost:8081/repository/maven-central

System properties (

) and environment variables (
) work too.

Using a Custom Repository for Dependencies

The thin launcher will use repository declarations from the

in the archive, and also from the
(by default, but can be relocated using
). If you have a private repository that requires credentials to access it, the best choice is
. This also applies to the Gradle plugin because it executes the jar file, and the underlying mechanism is implemented using Maven.


setting only applies to the location of the launcher jar itself. If your custom repo is not a mirror it is unlikely to be that location.


This project is Open Source software released under the Apache 2.0 license.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.