The Java buildpack detects if your build is Java by looking for a pom.xml or build.gradle file. If found, Maven/Gradle will download all dependencies and build the project.

Setting up your POM.XML file

If your app has any dependencies, the pom.xml file should include the maven-dependency-plugin.

It tells Maven to copy the jar files that your app depends on to the target/dependency directory.

Because we use Cloudnative Buildpacks, the pom.xml file needs to have a compatible structure to produce a correct build slug for Java.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""

Specify Java version

You can specify a Java version by adding a file called to your application.

Then set a java.runtime.version in the file:


Sample Java Procfile

Keep in mind, you must specify a PORT variable for the web process to expose the server to the internet.

web: java $JAVA_OPTS -cp target/classes:target/dependency/* com.example.MyJavaApplication