<commit_before>---
title: Java Buildpack
owner: Java
---

<strong><%= modified_date %></strong>

Use the Java buildpack with applications written in Grails, Play, Spring, or any
other JVM-based language or framework.

See the following topics:

* <a href="./java-tips.html" class="subnav">Tips for Java Developers</a>
* <a href="./getting-started-deploying-apps/index.html" class="subnav">Getting Started Deploying Apps</a>
* <a href="./configuring-service-connections/index.html" class="subnav">Configuring Service Connections</a>
* <a href="./sts.html" class="subnav">Cloud Foundry Eclipse Plugin</a>
* <a href="./java-client.html" class="subnav">Cloud Foundry Java Client Library</a>

See the [Java Buildpack Release Notes](https://github.com/cloudfoundry/java-buildpack/releases) for information about specific versions. 
You can find the source for the Java buildpack on GitHub: [https://github.com/cloudfoundry/java-buildpack](https://github.com/cloudfoundry/java-buildpack)

## <a id='logging'></a> Buildpack and Application Logging ##

The buildpack only runs during the staging process, and therefore only logs
staging information such as the downloaded components, configuration data, and work performed on your application by the buildpack.

The Java buildpack source documentation states the following:

* The Java buildpack logs all messages, regardless of severity, to
`APP-DIRECTORY/.java-buildpack.log`. The buildpack also logs messages to `$stderr`, filtered by a configured severity level.

* If the buildpack fails with an exception, the exception message is logged with
a log level of `ERROR`. The exception stack trace is logged with a log
level of `DEBUG`. This prevents users from seeing stack traces by default.

Once staging completes, the buildpack stops logging. The Loggregator handles application logging. 

Your application must write to STDOUT or STDERR for its logs to be included in
the Loggregator stream. For more information, see the [Application Logging in Cloud Foundry](../../devguide/deploy-apps/streaming-logs.html) topic.

## <a id='bosh-trusted-cert'></a> BOSH Custom Trusted Certificate Support

Java Buildpack versions 3.7 and later support [BOSH configured custom trusted certificates](http://bosh.io/docs/trusted-certs.html).

Run the following command to configure support for this feature:

<pre class="terminal">
$ cf set-env APP-NAME JBP_CONFIG_CONTAINER_CERTIFICATE_TRUST_STORE '{enabled: true}'`
</pre>

## <a id='memory-constraints'></a> Memory Constraints in Java Buildpack 4.0

The new memory calculator in Java Buildpack 4.0 accounts for the following memory regions:

<ul>
<li><code>-Xmx</code>: Heap</li>
<li><code>-XX:MaxMetaspaceSize</code>: Metaspace</li>
<li><code>-Xss</code>: Thread Stacks</li>
<li><code>-XX:MaxDirectMemorySize</code>: Direct Memory</li>
<li><code>-XX:ReservedCodeCacheSize</code>: Code Cache</li>
<li><code>-XX:CompressedClassSpaceSize</code>: Compressed Class Space</li>
</ul>

Applications which previously ran in 512&nbsp;MB or smaller containers may no longer be able to. Most applications will run if they use the Cloud Foundry default container size of 1G without any modifications. However, you can configure those memory regions directly as needed.

The Java buildpack optimizes for all non-heap memory regions first and leaves the remainder for the heap.

The Java buildpack builds a print a histogram of the heap to the logs when the JVM encounters a terminal failure.

The Cloud Foundry default Java buildpack is currently 3.x, in order to allow time for applications to upgrade to 4.x.

For more information, see [Java Buildpack 4.0](https://www.cloudfoundry.org/just-released-java-buildpack-4-0/).<commit_msg>Removed configuration step, added info about which content is pulled [#150683820]<commit_after>---
title: Java Buildpack
owner: Java
---

<strong><%= modified_date %></strong>

Use the Java buildpack with applications written in Grails, Play, Spring, or any
other JVM-based language or framework.

See the following topics:

* <a href="./java-tips.html" class="subnav">Tips for Java Developers</a>
* <a href="./getting-started-deploying-apps/index.html" class="subnav">Getting Started Deploying Apps</a>
* <a href="./configuring-service-connections/index.html" class="subnav">Configuring Service Connections</a>
* <a href="./sts.html" class="subnav">Cloud Foundry Eclipse Plugin</a>
* <a href="./java-client.html" class="subnav">Cloud Foundry Java Client Library</a>

See the [Java Buildpack Release Notes](https://github.com/cloudfoundry/java-buildpack/releases) for information about specific versions. 
You can find the source for the Java buildpack on GitHub: [https://github.com/cloudfoundry/java-buildpack](https://github.com/cloudfoundry/java-buildpack)

## <a id='logging'></a> Buildpack and Application Logging ##

The buildpack only runs during the staging process, and therefore only logs
staging information such as the downloaded components, configuration data, and work performed on your application by the buildpack.

The Java buildpack source documentation states the following:

* The Java buildpack logs all messages, regardless of severity, to
`APP-DIRECTORY/.java-buildpack.log`. The buildpack also logs messages to `$stderr`, filtered by a configured severity level.

* If the buildpack fails with an exception, the exception message is logged with
a log level of `ERROR`. The exception stack trace is logged with a log
level of `DEBUG`. This prevents users from seeing stack traces by default.

Once staging completes, the buildpack stops logging. The Loggregator handles application logging. 

Your application must write to STDOUT or STDERR for its logs to be included in
the Loggregator stream. For more information, see the [Application Logging in Cloud Foundry](../../devguide/deploy-apps/streaming-logs.html) topic.

## <a id='bosh-trusted-cert'></a> BOSH Custom Trusted Certificate Support

Java Buildpack versions 3.7 and later support [BOSH configured custom trusted certificates](http://bosh.io/docs/trusted-certs.html). Java Buildpack pulls the contents of `/etc/ssl/certs/ca-certificates.crt` and `$CF_INSTANCE_CERT/$CF_INSTANCE_KEY` by default.

The log output for Diego Instance Identity-based `KeyStore` will appear as follows:

<code>
Adding System Key Manager
Adding Key Manager for /etc/cf-instance-credentials/instance.key and /etc/cf-instance-credentials/instance.crt
Start watching /etc/cf-instance-credentials/instance.crt
Start watching /etc/cf-instance-credentials/instance.key
Initialized KeyManager for /etc/cf-instance-credentials/instance.key and /etc/cf-instance-credentials/instance.crt
</code>

The log output for Diego Trusted Certificate-based `TrustStore` will appear as follows:

<code>Adding System Trust Manager
Adding TrustManager for /etc/ssl/certs/ca-certificates.crt
Start watching /etc/ssl/certs/ca-certificates.crt
Initialized TrustManager for /etc/ssl/certs/ca-certificates.crt</code>

## <a id='memory-constraints'></a> Memory Constraints in Java Buildpack 4.0

The new memory calculator in Java Buildpack 4.0 accounts for the following memory regions:

<ul>
<li><code>-Xmx</code>: Heap</li>
<li><code>-XX:MaxMetaspaceSize</code>: Metaspace</li>
<li><code>-Xss</code>: Thread Stacks</li>
<li><code>-XX:MaxDirectMemorySize</code>: Direct Memory</li>
<li><code>-XX:ReservedCodeCacheSize</code>: Code Cache</li>
<li><code>-XX:CompressedClassSpaceSize</code>: Compressed Class Space</li>
</ul>

Applications which previously ran in 512&nbsp;MB or smaller containers may no longer be able to. Most applications will run if they use the Cloud Foundry default container size of 1G without any modifications. However, you can configure those memory regions directly as needed.

The Java buildpack optimizes for all non-heap memory regions first and leaves the remainder for the heap.

The Java buildpack builds a print a histogram of the heap to the logs when the JVM encounters a terminal failure.

The Cloud Foundry default Java buildpack is currently 3.x, in order to allow time for applications to upgrade to 4.x.

For more information, see [Java Buildpack 4.0](https://www.cloudfoundry.org/just-released-java-buildpack-4-0/).
{'fraction_non_alphanumeric': 0.10079316656497865, 'fraction_numerical': 0.0050030506406345335, 'mean_word_length': 5.139325842696629, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3587986', 'n_tokens_mistral': 2368, 'n_tokens_neox': 2267, 'n_words': 903}