Launching Executable Jars
| This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 4.1.1! |
The Launcher class is a special bootstrap class that is used as an executable jar’s main entry point.
It is the actual Main-Class in your jar file, and it is used to setup an appropriate ClassLoader and ultimately call your main() method.
There are three launcher subclasses (JarLauncher, WarLauncher, and PropertiesLauncher).
Their purpose is to load resources (.class files and so on) from nested jar files or war files in directories (as opposed to those explicitly on the classpath).
In the case of JarLauncher and WarLauncher, the nested paths are fixed.
JarLauncher looks in BOOT-INF/lib/, and WarLauncher looks in WEB-INF/lib/ and WEB-INF/lib-provided/.
You can add extra jars in those locations if you want more.
The PropertiesLauncher looks in BOOT-INF/lib/ in your application archive by default.
You can add additional locations by setting an environment variable called LOADER_PATH or loader.path in loader.properties (which is a comma-separated list of directories, archives, or directories within archives).
Launcher Manifest
You need to specify an appropriate Launcher as the Main-Class attribute of META-INF/MANIFEST.MF.
The actual class that you want to launch (that is, the class that contains a main method) should be specified in the Start-Class attribute.
The following example shows a typical MANIFEST.MF for an executable jar file:
Main-Class: org.springframework.boot.loader.launch.JarLauncher
Start-Class: com.mycompany.project.MyApplication
For a war file, it would be as follows:
Main-Class: org.springframework.boot.loader.launch.WarLauncher
Start-Class: com.mycompany.project.MyApplication
You need not specify Class-Path entries in your manifest file. The classpath is deduced from the nested jars. |
- Related Spring Documentation
- Spring Boot
- Spring Framework
- Spring Cloud
- Spring Cloud Build
- Spring Cloud Bus
- Spring Cloud Circuit Breaker
- Spring Cloud Commons
- Spring Cloud Config
- Spring Cloud Consul
- Spring Cloud Contract
- Spring Cloud Function
- Spring Cloud Gateway
- Spring Cloud Kubernetes
- Spring Cloud Netflix
- Spring Cloud OpenFeign
- Spring Cloud Stream
- Spring Cloud Task
- Spring Cloud Vault
- Spring Cloud Zookeeper
- Spring Data
- Spring Integration
- Spring Batch
- Spring Security
- Spring AI
- Spring AMQP
- Spring CLI
- Spring GraphQL
- Spring for Apache Kafka
- Spring Modulith
- Spring for Apache Pulsar
- Spring Shell All Docs...
