GoogleContainerTools/jib · error · IllegalStateException

The input JAR (${jarPath}) is compiled with Java ${jarJavaVe

Error message

The input JAR (${jarPath}) is compiled with Java ${jarJavaVersion}, but the default base image only supports versions up to Java 17. Specify a custom base image with --from.

What it means

When building from a JAR without an explicit base image (--from), jib-cli uses a default base image supporting Java up to 17. If the input JAR's class files report a Java major version above 17 and no custom base image was given, it throws IllegalStateException because the default base image cannot run the app.

Source

Thrown at jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ArtifactProcessors.java:68

  /**
   * Creates a {@link ArtifactProcessor} instance based on jar type and processing mode.
   *
   * @param jarPath path to the jar
   * @param cacheDirectories the location of the relevant caches
   * @param jarOptions jar cli options
   * @param commonContainerConfigCliOptions common cli options shared between jar and war command
   * @return ArtifactProcessor
   * @throws IOException if I/O error occurs when opening the jar file
   */
  public static ArtifactProcessor fromJar(
      Path jarPath,
      CacheDirectories cacheDirectories,
      Jar jarOptions,
      CommonContainerConfigCliOptions commonContainerConfigCliOptions)
      throws IOException {
    Integer jarJavaVersion = determineJavaMajorVersion(jarPath);
    if (jarJavaVersion > 17 && !commonContainerConfigCliOptions.getFrom().isPresent()) {
      throw new IllegalStateException(
          String.format(
              "The input JAR (%s) is compiled with Java %d, but the default base image only "
                  + "supports versions up to Java 17. Specify a custom base image with --from.",
              jarPath, jarJavaVersion));
    }
    String jarType = determineJarType(jarPath);
    ProcessingMode mode = jarOptions.getMode();
    if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.packaged)) {
      return new SpringBootPackagedProcessor(jarPath, jarJavaVersion);
    } else if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.exploded)) {
      return new SpringBootExplodedProcessor(
          jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);
    } else if (jarType.equals(STANDARD) && mode.equals(ProcessingMode.packaged)) {
      return new StandardPackagedProcessor(jarPath, jarJavaVersion);
    } else {
      return new StandardExplodedProcessor(
          jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);
    }

View on GitHub (pinned to fb949e2676)

Solutions

  1. Add --from=<base image supporting your Java version>, e.g. --from=eclipse-temurin:21
  2. Build the JAR targeting Java 17 or lower (javac --release 17 / Gradle toolchain)
  3. Pin the CI JDK to <= 17 if using the default base image

Example fix

// before
jib jar --target=gcr.io/project/app app.jar
// after
jib jar --from=eclipse-temurin:21 --target=gcr.io/project/app app.jar
Defensive patterns

Strategy: validation

Validate before calling

int major = determineJavaMajorVersion(jarPath); if (major > 17 && fromImage == null) { /* supply --from before invoking jib */ }

Try / catch

try { processor.fromJar(jarPath, ...); } catch (IllegalStateException e) { /* prompt user / retry with an explicit --from base image */ }

Prevention

When it happens

Trigger: Running `jib jar app.jar` (or via the Jar processor) on a JAR compiled with Java 18+ (class major version >= 62) while omitting --from.

Common situations: Upgrading the project's JDK/toolchain (e.g. Java 17 -> Java 21) but not updating the jib-cli invocation; CI builds picking up a newer JDK than expected.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/0ffa4ade468927a8. Report an issue: GitHub.