In my Eclipse photon version 2018 try to execute my code using TestNG while facing this error.

Kindly refer the error at my console

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/testng/TestNGException 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(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.privateGetMethodRecursive(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

Created the Maven project and add the required dependencies Selenium-java 3.141.59,testng 6.14.3,poi 5.0.0,poi-ooxml 5.0.0 and try to run my code at src/test/java it shows the error and exception.

Hence I tried to change JDK version as 11.0.10 even verified in command prompt which shows java version "11.0.10" 2021-01-19 LTS. And I make the changes in environment variable that system variable path as C:\Program Files\Java\jdk-11.0.10\bin . After I try to change build path in JRE System Library [JavaSE-1.8] as JRE 11th version in Alternate JRE but couldn't.

0

There are 0 best solutions below