Class has been compiled by a more recent version of the Java Environment
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
org/testng/ITestListener has been compiled by a more recent version of the Java Runtime (class file version 55.0), only recognizes version up to 52
As noted in the comments, the TestNG website says:
Requirements
TestNG Upto v7.5: JDK 8 or higher.
TestNG v7.6.0 and above: JDK 11 or higher.
So the possible solutions are:
Use an older version of TestNG than v7.6.0 if you want to use Java 8 as your development platform. The TestNG version will probably be in your project's POM file.
Upgrade your development platform to Java 11 or later.
If you are feeling brave1, attempt to backport the version of TestNG (>= v7.6.0) that you are using to run on Java 8 (or older).
1 - This could be trivial or complicated. You won't know until you try it.
CamelContextAware has been compiled by a more recent version of the Java Runtime
The problem was here
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit5</artifactId>
<version>3.15.0</version>
<scope>test</scope>
</dependency>
Setting version at 3.12.0
solved for me.
Spring Boot Application has been compiled by more recent version of Java runtime
Update: I solved the issue by removing the javapath path variable and restarting.
I believe it was the following I removed:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
JNI error : A class has been compiled by a more recent version of the Java Runtime
So, the problem is that you're compiling with javac
from JDK 11, and then trying to run with Java 8. Since the java.exe from %JAVA_HOME%\bin
is being picked up before C:\Program Files\Java\jdk-11.0.2\bin
. And, I'm guessing it can't find javac
because you added C:\Program Files\Java\jdk-11.0.2\bin
to the path, without restarting your shell, which means the path is not reloaded.
To resolve this you should remove the C:\Program Files\Java\jdk-11.0.2\bin
entry from the path, and then update the JAVA_HOME
environment variable to point to C:\Program Files\Java\jdk-11.0.2
instead. Then restart your shell and it should pick up C:\Program Files\Java\jdk-11.0.2\bin
expanded from %JAVA_HOME%\bin
.
Class compiled by a more recent version of the Java Runtime (0.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Your statement
return new ClassWriter(classReader,
ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES).toByteArray();
create a new ClassWriter
but doesn’t write anything to it before requesting the generated bytecode.
You have to populate it with the class information. In your specific case:
ClassWriter cw = new ClassWriter(classReader,
ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
classNode.accept(cw);
return cw.toByteArray();
Like classReader.accept(classNode, ClassReader.EXPAND_FRAMES);
copied all information from the class reader to the classNode
, the classNode.accept(cw);
will copy the modified information from the classNode
to the class writer.
To answer the question literally, a call tovisit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
will specify the main information of the class, including the version number, however, the method will be invoked automatically when using the Visitor Pattern.
Related Topics
Converting Many 'If Else' Statements to a Cleaner Approach
How to Use a Custom Font in Java
Does Setting Java Objects to Null Do Anything Anymore
Format Double Value in Scientific Notation
How to Use the Instanceof Operator in a Switch Statement
Noclassdeffounderror on Maven Dependency
Password Protected Zip File in Java
Why Does the First Panel Added to a Frame Disappear
Does a Finally Block Always Run
@Runwith(Mockitojunitrunner.Class) VS Mockitoannotations.Initmocks(This)
Bypass Generatedvalue in Hibernate (Merge Data Not in Db)
Most Efficient Way to Increment a Map Value in Java
Connect 4 Check for a Win Algorithm
How to Use Java.String.Format in Scala