Learn how to push your Java app to VMware Tanzu Application Service for VMs (TAS for VMs) and how to configure your app to use the Java Native Image Buildpack. VMware discourages using the Java Native Image Buildpack with production workloads while it is in beta.

Push an app using the Java Native Image Buildpack

Follow these procedures to use the Java Native Image Buildpack.

Deploy Java apps

The Java Native Image Buildpack is based on the Paketo Java Native Image Buildpack. The Paketo Documentation for the Buildpack describes how to push your Java app.

For more in-depth documentation, see the Tanzu documentation for the Java Native Image Buildpack.

To push an app with the Java Native Image Buildpack, you must follow these steps:

  1. Push the app code without starting the app, and configure a high-memory value.

    cf push myApp \
      -b java_native_image_cnb_beta -s tanzu-jammy-full-stack \
      --no-start -m 8G
    

    Before you can stage the app, you must set the environment variables. Additionally, the buildpack uses a lot of memory.

  2. Set the memory value to at least 4 GB but ideally 8 GB of memory.

  3. Set this required environment variable for Java Native Image applications.

    cf set-env myApp BP_NATIVE_IMAGE true
    

    Depending on the specifics for the app, other environment variables might be required.

  4. Start the app:

    cf start myApp
    

The following examples are based on common use cases.

Deploy Spring Boot 3.0.x apps

During step 2, you set the BP_NATIVE_IMAGE environment variable. You might also set the following variables:

cf set-env myApp BP_MAVEN_BUILD_ARGUMENTS \
"-Dmaven.test.skip=true --no-transfer-progress package -Pnative"
cf set-env myApp BP_JVM_VERSION 17

Deploy Spring Boot 3.1.x apps

During step 2, you set the BP_NATIVE_IMAGE environment variable. You might also set the following variable:

cf set-env myApp BP_MAVEN_ACTIVE_PROFILES native

Deploy Spring Boot apps with Gradle

No additional environment variables are necessary to deploy Spring Boot apps with Gradle.

Deploy Quarkus apps

During step 2, you set the BP_NATIVE_IMAGE environment variable. You might also set the following variables:

cf set-env myApp BP_MAVEN_BUILD_ARGUMENTS "-Dquarkus.package.type=native-sources \
-Dmaven.test.skip=true package"
cf set-env myApp BP_MAVEN_BUILT_ARTIFACT "target/native-sources"
cf set-env myApp BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE= native-sources/native-image.args"
cf set-env myApp BP_NATIVE_IMAGE_BUILT_ARTIFACT "<PATH-TO-JAR-FILE>"
cf set-env myApp BP_JVM_VERSION=17

Supported versions

This version of TAS for VMs supports Java Native Image CNB 7.6.1.

Help and support

Join the #buildpacks channel in our Slack community if you need help.

check-circle-line exclamation-circle-line close-line
Scroll to top icon