Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsupportedClassVersionError: com/google/googlejavaformat/java/Main has been compiled by a more recent version of the Java Runtime #3

Closed
TimeForANinja opened this issue May 6, 2020 · 5 comments

Comments

@TimeForANinja
Copy link

Hey,

getting the following Runtime-Error for all my builds

Run axel-op/googlejavaformat-action@v2.0.0
  with:
    args: --replace
    files: **/*.java
    skipCommit: false
/usr/bin/curl -sL https://github.com/google/google-java-format/releases/download/google-java-format-1.8/google-java-format-1.8-all-deps.jar -o /home/runner/google-java-format.jar
/usr/bin/java -jar /home/runner/google-java-format.jar --version
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/googlejavaformat/java/Main has been compiled by a more recent version of the Java Runtime (class file version 55.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:757)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
##[error]Error: The process '/usr/bin/java' failed with exit code 1

using ubuntu-latest without any manual changes 🤔

@axel-op axel-op pinned this issue May 6, 2020
@axel-op
Copy link
Owner

axel-op commented May 6, 2020

Hey, the latest version of Google Java Format requires JDK 11 at least, and by default ubuntu-latest is executed with JDK 8, that's why you have this error (see #2).

I published a new version of my action a few days ago (v3.0.0), that will automatically use a previous version of Google Java Format if you don't use JDK 11 or further.

However I strongly recommend you to switch to a more recent JDK if possible. You can do so simply by adding a step before executing this action, as indicated in the README:

jobs:

  formatting:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1 # Add this step (if possible)
        with:
          java-version: "11"
      - uses: axel-op/googlejavaformat-action@v3.0.0 # Change version tag here
        with:
          args: "--skip-sorting-imports --replace"

@axel-op axel-op changed the title Java Runtime error UnsupportedClassVersionError May 6, 2020
@TimeForANinja
Copy link
Author

👍 yep that solved it - builds now passing

@axel-op axel-op changed the title UnsupportedClassVersionError UnsupportedClassVersionError: com/google/googlejavaformat/java/Main has been compiled by a more recent version of the Java Runtime Jul 12, 2020
@hantsy
Copy link

hantsy commented Jan 28, 2021

Got the same issue, but if I added Java version, the build task will be ignored completely in my case.

https://github.com/hantsy/cargotracker/pull/11/checks?check_run_id=1782645512

@hantsy
Copy link

hantsy commented Jan 28, 2021

I found the reason when I set up Java 11, I can not set version arg for this action, else it will be ignored.

@axel-op
Copy link
Owner

axel-op commented Jan 29, 2021

I found the reason when I set up Java 11, I can not set version arg for this action, else it will be ignored.

Hi, I don't understand what you mean. The version input is always taken into account, even when you set Java 11 as your JDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants