score:296

Accepted answer

this is just a version mismatch. you have compiled your code using java version 9 and your current jre is version 8. try upgrading your jre to 9.

49 = java 5
50 = java 6
51 = java 7
52 = java 8
53 = java 9
54 = java 10
55 = java 11
56 = java 12
57 = java 13
58 = java 14
59 = java 15
60 = java 16
61 = java 17
62 = java 18
63 = java 19

score:0

this is getting as an example if your computer running on an older version of java and the neo4j is compiled on the latest version, please try to install the same version or upper to your computer.

score:0

i'm getting the same problem with sonarqube

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

sonarqube with azuredevops error output:

info: sonarscanner 4.6.2.2472
info: java 1.8.0_231 oracle corporation (32-bit)
info: windows server 2016 10.0 x86
info: user cache: c:\windows\system32\config\systemprofile.sonar\cache
info: scanner configuration file: c:\agent_a_work_tasks\sonarqubeprepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin..\conf\sonar-scanner.properties
info: project root configuration file: c:\agent_a_work\189.sonarqube\out\sonar-project.properties
info: analyzing on sonarqube server 9.4.0
info: default locale: "en_au", source code encoding: "windows-1252" (analysis is platform dependent)
info: ------------------------------------------------------------------------
info: execution failure
info: ------------------------------------------------------------------------
info: total time: 0.405s
info: final memory: 3m/15m
##[error]error: error during sonarscanner execution
java.lang.unsupportedclassversionerror: org/sonar/batch/bootstrapper/environmentinformation 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


i had java v11 installed on the sonarcube server, but the error is saying its the build agent that doesn't have java v11.

i decided to add the java v12 bin path to the environment variable path for it to be detected. important this needs to be done on the build agent:

enter image description here

for a hosted build agent you can install jdk v11 or use this powershell script step:

- task: powershell@2
  displayname: 'download and install java v11'
  inputs:
    targettype: 'inline'
    script: |
      [net.servicepointmanager]::securityprotocol = [net.securityprotocoltype]::tls12
      $command = "c:\jdk-11.0.15_windows-x64_bin.exe"
      $parms = "/s"
      write-host [system.io.file]::exists($command)
      if ([system.io.file]::exists($command)) {
        write-host 'downloading java11.exe'      
        invoke-webrequest https://yourownurl.com/jdk-11.0.15_windows-x64_bin.exe -outfile $command
      }
      write-host [system.io.file]::exists($command)
      & "$command" $prms
      [system.environment]::setenvironmentvariable("java_home", "c:\program files\java\jdk-11.0.15")
      [system.environment]::setenvironmentvariable("path", [system.environment]::getenvironmentvariable('path', [system.environmentvariabletarget]::machine) + ";$($env:java_home)\bin")

score:0

in my case, i'm building with vs2019 some c++ code that is using antlr4. antlr4 is java based, and to use it i run java commands as a custom build step.

earlier that day i had updated my jre (java runtime environment) on my new laptop to 1.8. not thinking, since it's been a year since i ran antlr4 stuff... i need the full jdk to compile with java. so i had a 1.8 runtime, but the vs2019 build shell was finding the jdk1.7 compiler. once i installed the 1.8 jdk, all was good.

so 80% of the time jre is fine for me... it's just when i need the full jdk, doh i need the full jdk.

score:0

in build.gradle(app) update as below: (worked for me)

 kotlinoptions {
        jvmtarget = '1.8'
    }

score:0

for me this problem was resolved by just installing older version of testng. looks like it compiles with my java 8

score:0

if you're using intellij idea and having this error, try this.

1. command + , (open preferences)
2. build, execution, deployment > build tools > gradle
3. gradle jvm > change it to a proper version

score:1

go to project section, click on properties > then to java compiler > check compiler compliance level is 1.8 , or there should be no yellow warning at bottom

score:1

refreshing gradle dependencies works for me: right click over the project -> gradle -> refresh gradle project.

score:1

i faced this error in intellij. apparently, choosing java 1.8 as the project sdk doesn't affect the javac compiler that's used to build the project.

to change that, go to settings -> build, execution, deployment -> compiler -> java compiler, and change project bytecode version to 8.

score:1

i've reproduced on windows 10 the similar issue in format like:

error: linkageerror occurred while loading main class ...
java.lang.unsupportedclassversionerror: com/.../serviceapplication 
has been compiled by a more recent version of the java runtime (class file version 62.0), 
this version of the java runtime only recognizes class file versions up to 61.0

after upgrading the project from java 17 to java 18.

i had project settings regarding to java 18:

  1. command line:
java version "18.0.1.1" 2022-04-22
java(tm) se runtime environment (build 18.0.1.1+2-6)
java hotspot(tm) 64-bit server vm (build 18.0.1.1+2-6, mixed mode, sharing)

enter image description here

  1. project structure -> project settings -> project:

enter image description here

  1. project structure -> project settings -> modules:

enter image description here

  1. project structure -> platform settings -> sdks:

enter image description here

and the reason of this issue was:

i forgot to specify the correct version for run/debug configurations -> build and run to java 18 instead of java 17:

enter image description here

as it was compiled with a newer java version, but running on the older one.


if it's maven-related issue, you can modify pom by specifying the -source and -target of the java compiler.


additional helpful links:

  1. setting the java version in maven
  2. consuming jar artifact of a specific java version

score:2

you should check your project facets.

project properties > project facets

change java version to the same version you are using. that work for me!

score:2

ide : eclipse 2021-09

this is caused because you have compiled the code with java version 9 and have java8 installed. you don't have to update to solve this issue.

right click on project > properties > java compiler > untick-enable project specific settings > configure workspace settings > tick-use default compliance settings > apply and close.


now your code should be executed properly.

score:3

i'm writing this because i found the other answers hard to understand.

essentially your jre is not updated and/or eclipse is not configured to use the most recent jre.

on windows, go to control panel -> programs -> java -> update and proceed to update java

or if you don't have java, go to oracle's website and download the most recent jre.

once this is done, go into eclipse, and under the project view, right click on your project, select java build path, double click on jre system library, then select workspace default jre 14.1.

if a recent version of java doesn't show up here, it probably isn't installed. check you jre(not jdk) version and make sure it's recent. if it is, try restarting the computer then trying this again.

score:3

your jdk version: java 8
your jre version: java 9

here your jre version is different than the jdk version that's the case. here you can compile all the java classes using jdk version 1.8. if you want to compile only one java class just change the *.java into <yourclassname>.java

javac -source 1.8 -target 1.8  *.java

source: the version that your source code requires to compile.
target: the oldest jre version you want to support.

score:5

i had a similar issue from the console after building a jar in intellij. using the java configuration to update to a newer version (windows -> configure java -> update -> update now) didn't work and stuck at version 1.8 (java 8).

to switch to a more recent version locally i had to install the java 15 jdk from https://www.oracle.com/uk/java/technologies/javase-jdk15-downloads.html and add that to my java runtime environment settings.

java runtime environment settings

score:6

for temporary solution just right click on project => properties => java compiler => over there please select compiler compliance level 1.8 => .class compatibility 1.8 => source compatibility 1.8.

then your code will start to execute on version 1.8.

score:8

53 stands for java-9, so it means that whatever class you have has been compiled with javac-9 and you try to run it with jre-8. either re-compile that class with javac-8 or use the jre-9

score:8

you might see this error in intellij as well and this comes up in google.

i think it's a gradle error more than an ide error.

the fix (stolen from here) is configure java 11 as a gradle jvm in intellij:

file -> settings -> build, execution & development -> build tools -> gradle and change gradle jvm to 11

enter image description here

that screenshot stolen from the jetbrains issue as well

score:20

you can try this way

javac --release 8 yourclass.java

score:60

ide: eclipse oxygen.3

to temporarily correct the problem do the following:

project menu > properties > java compiler > compiler compliance level > 1.8

a permanent fix likely involves installing jdk 9.

fyi 1.8 is what java 8 is called.

side bar

i recently returned to java after a foray into c# (a breath of fresh air) and installed eclipse oxygen onto a clean system that had never had java installed on it before. this default everything with a brand new install of eclipse oxygen yet somehow or other eclipse can't get its own parameters to match the jdk that's installed. this is the second project i created and the second time i ran into this headache. time to go back to c#?

related question

has been compiled by a more recent version of the java runtime (class file version 53.0)


Related Query

More Query from same tag