The Java Main Container allows an application that provides a class with a main() method to be run. The application is executed with a command of the form:
<JAVA_HOME>/bin/java -cp . com.gopivotal.SampleClassCommand line arguments may optionally be configured.
| Detection Criteria | Main-Class attribute set in META-INF/MANIFEST.MF, or java_main_class set in JBP_CONFIG_JAVA_MAIN |
| Tags | java-main |
If the application uses Spring, Spring profiles can be specified by setting the SPRING_PROFILES_ACTIVE environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the cloud profile in addition to any others.
If java_main_class is set to one of Spring Boot's launchers (JarLauncher, PropertiesLauncher or WarLauncher), the Java Main Container sets SERVER_PORT=$PORT so that the application binds to the CF-assigned port.
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to Configuration and Extension.
The container can be configured using the JBP_CONFIG_JAVA_MAIN environment variable.
| Name | Description |
|---|---|
arguments |
Optional command line arguments to be passed to the Java main class. The arguments are specified as a single YAML scalar in plain style or enclosed in single or double quotes. |
java_main_class |
Optional Java class name to run. Values containing whitespace are rejected with an error, but all others values appear without modification on the Java command line. If not specified, the Java Manifest value of Main-Class is used. Setting this overrides container detection — even Spring Boot apps will use the Java Main container when this is set. |
env:
JBP_CONFIG_JAVA_MAIN: '{java_main_class: "org.springframework.boot.loader.launch.PropertiesLauncher", arguments: "--loader.home=/home/vcap/data"}'
JAVA_OPTS: '-Dloader.path=/home/vcap/data/lib'