## 4.1.3.5.1.2.5  Java Main
You can create a Java application that starts its own runtime. This allows the usage of frameworks and Java runtimes, such as Spring Boot, Jetty, Undertow, or Netty.
## Prerequisites
- You are not using the Resource Configuration [page 318] feature of the buildpack.
##  Note
The resource configurations needed for the database connection are not applicable for Java Main applications. For more information about database connections, see: Configuring a Database Connection [page 341]
## Context
In this section, applications like this are referred as Java Main applications . The application container provided by SAP Java/Jakarta Buildpack for running Java Main applications is referred as Java Main container .
## Procedure
1. Make sure your built JAR archive is configured properly.
Regardless of the tool you use to build your Java application, you have to make sure that the following tasks are performed:
- a. You have built a JAR archive.
- b. You have specified a main class in the META-INF/MANIFEST.MF file of the JAR archive.
- c. You have packaged all your dependent libraries in the JAR file, also known as creating an uber JAR or a flat JAR .
<!-- image -->
If you are using Maven as your build tool, you can use the maven-shade-plugin to perform the above tasks.
```
 Sample Code Sample configuration for the maven-shade-plugin <build> <finalName>java-main-sample</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.3</version> <configuration> <createDependencyReducedPom>false</createDependencyReducedPom> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTra nsformer" /> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTra nsformer"> <manifestEntries> <Main-Class>com.sap.xs.java.main.Controller</Main-Class> </manifestEntries> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build>
```
2. Configure the manifest.yml .
To be able to push the Java Main application, you need to specify the path to the .jar archive in the manifest.yml file.
<!-- image -->
```
instances: 1
```
3. (Optional) If you use SAP HANA JDBC, we recommend that you include the dependent JAR files in the uber JAR. Then refer these files, as a space separated list, in the Class-Path header field of the MANIFEST.MF file. For example:
4. Deploy the application on Cloud Foundry. Execute:
<!-- image -->
cf push
## Example
To create a Java Main application that is using its own runtime, proceed as follows:
1. Create an application, named sample\_main . Use Spring Boot for that purpose.
2. Navigate to the sample\_main directory of the application, using the command line tool, and build it. To do that, execute:
3. After the successful build, check that the sample\_main directory of the application contains a sample\_main.jar file.
4. Open the sample\_main.jar file and check that the META-INF/MANIFEST.MF file contains the Main-Class header, whose value is the name of the main class.
5. Add the path to the JAR file in the manifest.yml file. You need to do this to make sure that the application can be pushed to the Cloud Foundry environment. For
6. that purpose, add the following line in the manifest.yml file:
6. Finally, deploy the Java Main application. Execute:
```
mvn clean install
```
```
path: ./target/sample_main.jar
```
```
cf push sample_main
```