{"record":{"id":"0ffa4ade468927a8","repo":"GoogleContainerTools/jib","slug":"the-input-jar-jarpath-is-compiled-with-java","errorCode":null,"errorMessage":"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.","messagePattern":"The input JAR \\((.+?)\\) is compiled with Java (.+?), but the default base image only supports versions up to Java 17\\. Specify a custom base image with --from\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ArtifactProcessors.java","lineNumber":68,"sourceCode":"  /**\n   * Creates a {@link ArtifactProcessor} instance based on jar type and processing mode.\n   *\n   * @param jarPath path to the jar\n   * @param cacheDirectories the location of the relevant caches\n   * @param jarOptions jar cli options\n   * @param commonContainerConfigCliOptions common cli options shared between jar and war command\n   * @return ArtifactProcessor\n   * @throws IOException if I/O error occurs when opening the jar file\n   */\n  public static ArtifactProcessor fromJar(\n      Path jarPath,\n      CacheDirectories cacheDirectories,\n      Jar jarOptions,\n      CommonContainerConfigCliOptions commonContainerConfigCliOptions)\n      throws IOException {\n    Integer jarJavaVersion = determineJavaMajorVersion(jarPath);\n    if (jarJavaVersion > 17 && !commonContainerConfigCliOptions.getFrom().isPresent()) {\n      throw new IllegalStateException(\n          String.format(\n              \"The input JAR (%s) is compiled with Java %d, but the default base image only \"\n                  + \"supports versions up to Java 17. Specify a custom base image with --from.\",\n              jarPath, jarJavaVersion));\n    }\n    String jarType = determineJarType(jarPath);\n    ProcessingMode mode = jarOptions.getMode();\n    if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.packaged)) {\n      return new SpringBootPackagedProcessor(jarPath, jarJavaVersion);\n    } else if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.exploded)) {\n      return new SpringBootExplodedProcessor(\n          jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);\n    } else if (jarType.equals(STANDARD) && mode.equals(ProcessingMode.packaged)) {\n      return new StandardPackagedProcessor(jarPath, jarJavaVersion);\n    } else {\n      return new StandardExplodedProcessor(\n          jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);\n    }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ArtifactProcessors.java#L50-L86","documentation":"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.","triggerScenarios":"Running `jib jar app.jar` (or via the Jar processor) on a JAR compiled with Java 18+ (class major version >= 62) while omitting --from.","commonSituations":"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.","solutions":["Add --from=<base image supporting your Java version>, e.g. --from=eclipse-temurin:21","Build the JAR targeting Java 17 or lower (javac --release 17 / Gradle toolchain)","Pin the CI JDK to <= 17 if using the default base image"],"exampleFix":"// before\njib jar --target=gcr.io/project/app app.jar\n// after\njib jar --from=eclipse-temurin:21 --target=gcr.io/project/app app.jar","handlingStrategy":"validation","validationCode":"int major = determineJavaMajorVersion(jarPath); if (major > 17 && fromImage == null) { /* supply --from before invoking jib */ }","typeGuard":null,"tryCatchPattern":"try { processor.fromJar(jarPath, ...); } catch (IllegalStateException e) { /* prompt user / retry with an explicit --from base image */ }","preventionTips":["Always pass --from when your build targets Java > 17","Pin the project's Java toolchain so jar and base image versions match","Check the JDK version in CI before invoking jib"],"tags":["jib","cli","java-version","base-image"],"backgroundTag":"incompatible-source-type","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}