Jib: Java 10 support?

Created on 11 Jul 2018  路  15Comments  路  Source: GoogleContainerTools/jib

Description of the issue:
Running a Java10 compiled, jib built image fails:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: c/z/o/App has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

Expected behavior:
App should run?
Steps to reproduce:
Compile with java10
Environment:
Maven

Most helpful comment

I suppose we could hard-code a check that if a <from> image isn't specified then we check the maven compiler settings. Or better yet, use the Maven compiler settings to determine the <from> image when not specified.

All 15 comments

Jib uses gcr.io/distroless/java as the base image by default, which uses openjdk8. For Java 10, I think you should find a reliable base image with Java 10, and configure Jib to use it (pom.xml).

+1 @chanseokoh

For example, you could try using openjdk:10-jre as your from image.

@coollog I tried that and it failed as unauthorized. Do I need credentials for the public image?
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/openjdk","Action":"pull"}]}]}

@aclowkey We are cutting a release of version 0.9.4 soon with a fix for that issue (https://github.com/GoogleContainerTools/jib/pull/549)

@coollog should we file a FR against distroless/java for more up-to-date java support? Jib should be able to pick the right base-image based off of the maven/gradle java config.

I suppose we could hard-code a check that if a <from> image isn't specified then we check the maven compiler settings. Or better yet, use the Maven compiler settings to determine the <from> image when not specified.

@aclowkey Can you try again with version 0.9.4?

@coollog Works! Image size is 200Mb more tho. Default produces an image size of 77Mb, with JDK10 it comes out as ~270Mb

@aclowkey Yea, openjdk images tend to be larger than distroless. Did you try using openjdk:10-jre-slim? It's a lot smaller than openjdk:10-jre (286MB vs 632MB).

@coollog Much better! ~130Mb

Doesn't really make sense to address this until we have blessed images for other JRE versions.

We will skip Java 10 and add support for detection and use of LTS Java 11 version of gcr.io/distroless/java once it is available.

Java 11 Distroless is available, and Jib uses it by default for Java 9+ apps. (#1279, #1510).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shijiaoming picture shijiaoming  路  4Comments

anuraaga picture anuraaga  路  6Comments

jack-kerouac picture jack-kerouac  路  6Comments

joerg1985 picture joerg1985  路  3Comments

schmitch picture schmitch  路  3Comments