Java

Detected from Maven or Gradle files. Builds with a wrapper when you commit one.

See Buildpacksfor how detection and version policy work.

Detects

pom.xml (or polyglot pom.*), build.gradle, build.gradle.kts, settings.gradle, settings.gradle.kts, mvnw, or gradlew.

Versions

Default is Java 21. Published lines as of September 2026: 11, 17, 21, 25, 26. You get the latest patch of the requested line. The build uses an Eclipse Temurin JDK. The run image uses the matching JRE.

Pin in system.properties:

java.runtime.version=21

Forms like 21, 21.0.12, or temurin-21 work. Java 8 is not supported.

Install and build

  • gradlew: ./gradlew build -x test --no-daemon
  • mvnw: ./mvnw -B -DskipTests clean package
  • A Maven POM without a wrapper: Nodion’s Maven, same goals

A Gradle project without gradlew fails. Commit the wrapper.

Launch sets JAVA_HOME to the JRE and defaults JAVA_TOOL_OPTIONS to -XX:MaxRAMPercentage=80.0. Override that env if you need different heap behavior.

Start command

java -Dserver.port=$PORT $JAVA_OPTS -jar <jar>. The jar is the largest file in target/ or build/libs/, ignoring -plain, -sources, and -javadoc jars. If none is found, add a Procfile. Listen on PORT.