Docs / Java

Deploy Java

Spring Boot or any runnable jar on Java 21.

Java apps need the Starter plan or a bigger one. See pricing.

Detected by

pom.xml, build.gradle, build.gradle.kts or a .jar file at the top of the project. The general rules are in Deploying.

Build

  • Maven 3.9 (mvn package, tests skipped) or Gradle 8 (bootJar, else jar) on JDK 21.
  • We run the jar from target/ (Maven) or build/libs/ (Gradle) on a Java 21 runtime.
  • Or upload a zip with exactly one runnable .jar and no build file; we run it as it is.

Start

Always java -jar with -Dserver.port=$PORT, and the heap sized to your plan's memory. Spring Boot picks up the port by itself; other frameworks should read PORT.

Example

application.properties

server.port=${PORT:8080}
spring.datasource.url=jdbc:postgresql://db.systemi.in:5433/app_123?sslmode=require
spring.datasource.username=app_123
spring.datasource.password=${DB_PASSWORD}
server.forward-headers-strategy=framework

Frameworks

FrameworkStart command or setting
Spring Bootnothing to set; spring-boot-maven-plugin makes the runnable jar
Quarkus, Micronaut, othersbuild an uber-jar that reads PORT and upload it as a prebuilt jar

Good to know

  • With Maven, the jar must be runnable on its own (a fat jar). Spring Boot's plugin does this; a plain library jar won't start.
  • Builds of large projects are quicker as a prebuilt jar: run mvn package on your machine or in CI and zip the jar.
  • Spring Boot's first start is the slowest part of a deploy; lazy initialisation (spring.main.lazy-initialization=true) helps.