class file has wrong version 55.0, should be 52.0

13,101 views
Skip to first unread message

Hari Daggubati

unread,
Jul 20, 2023, 9:04:34 AM7/20/23
to testng-users
I am using IntelliJ IDEA for testing.

IntelliJ IDEA Version:

IntelliJ IDEA 2018.3.6 (Community Edition)
Build #IC-183.6156.11, built on March 25, 2019
JRE: 1.8.0_152-release-1343-b28 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.19.0-46-generic


 I have added TestNG framework to IDE by adding the dependency in pom.xml file.

TestNG Dependency:

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.8.0</version>
    <scope>test</scope>
</dependency>

Java version:

openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1)
OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1, mixed mode, sharing)

when i am running the code(  in IntellijIDEA i am getting below error

Error:

Information:java: Errors occurred while compiling module 'FirstTest'
Information:javac 8 was used to compile java sources
Information:Module "FirstTest" was fully rebuilt due to project configuration/dependencies changes
Information:20/7/23 5:29 PM - Compilation completed with 1 error and 3 warnings in 1 s 350 ms
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.
/home/nxtwavetechhari/FirstTest/src/test/java/LoginPageTest.java
Error:(11, 30) java: cannot access org.testng.annotations.Test
  bad class file: /home/nxtwavetechhari/.m2/repository/org/testng/testng/7.8.0/testng-7.8.0.jar(org/testng/annotations/Test.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

pom.xml file: 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>first-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.9.1</version>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.8.0</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>

mvn version:

Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.19, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-46-generic", arch: "amd64", family: "unix"

May I know the reason behind this error? and please let me know the solution to this.

Thanks in advance

⇜Krishnan Mahadevan⇝

unread,
Jul 20, 2023, 9:05:45 AM7/20/23
to testng...@googlegroups.com
You can only use upto 7.5.1 if you are on JDK8.

TestNG 7.6 and above needs JDK11.

So if you want to use TestNG 7.8.0 please use JDK11.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/e02acb0b-dadd-4fc9-b659-47711aeeb21bn%40googlegroups.com.

Hari Daggubati

unread,
Jul 20, 2023, 11:45:08 PM7/20/23
to testng-users
Thank you Krishnan Mahadevan for the response

But as I mentioned in the above message I am using JDK 11 only even though I am getting that error.

TIA

⇜Krishnan Mahadevan⇝

unread,
Jul 21, 2023, 12:27:54 AM7/21/23
to testng...@googlegroups.com
Hari,
No, I don't think that's what is happening here.
The error clearly states that IntelliJ is resolving to JDK8 for your execution. Please have this fixed.
One easy way of ensuring that IntelliJ honours your JDK ask is by setting the JDK version in the maven compiler plugin of your pom file and then importing this project into intellij as a maven project.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Reply all
Reply to author
Forward
0 new messages