2

I did the downgrade of java 8 to java 7 and I am unable to run my project.

My eclipse configurations are:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

My pom.xml file:

<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>br.usp.icmc.jenkins.saucelabs</groupId>
    <artifactId>JenkinsSaucelabs</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>JenkinsSaucelabs</name>
    <description>JenkinsSaucelabs</description>

    <dependencies>
        <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <version>4.11</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20141113</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <!-- Dependente da versão da JDK -->
            <classifier>jdk15</classifier>
        </dependency>
        <!-- Jersey -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
            <version>1.11</version>
        </dependency>

        <!-- Json -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>1.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>0.11</version>
        </dependency>

        <dependency>
            <groupId>com.restfb</groupId>
            <artifactId>restfb</artifactId>
            <version>1.11.0</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3.1</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>TesteJSONSauceLabs</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

I have tested the alternatives of posts:

Eclipse JRE System Library [J2SE-1.5]

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Stacktracer:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/json/JSONObject : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at br.usp.icmc.teste.ConnectionRestClient.getSaucelabsJobsByID(ConnectionRestClient.java:30)
    at br.usp.icmc.teste.TestePrincipal.main(TestePrincipal.java:8)

Why am I receiving an UnsupportedClassVersionError exception with Unsupported major.minor version 52.0? Where am I wrong?

Community
  • 1
  • 1
ricardoramos
  • 861
  • 3
  • 16
  • 33

2 Answers2

1

You are running your application with the incorrect version of java, or some of the dependencies you are using are compiled for java 8.

Check that your JAVA_HOME is pointing to the correct java installation and that Eclipse truely uses Java 7.

Adrian B.
  • 1,493
  • 1
  • 19
  • 35
1

After you changed the Java version being used in the POM file, did you refresh the project's dependencies in Eclipse?

In Eclipse Luna (and possibly Eclipse Mars), this is done by pressing Alt-F5 or by right clicking a Maven project, choosing the Maven menu, then clicking the Update Projects button.

This brings up a new dialog that looks something like this:

Update Maven Project

All Maven projects in the current Eclipse workspace should be shown. In the above example, this is a parent project with multiple child projects.

You should select all Maven projects in your workspace, then click OK.

This should force Maven to refresh all the dependencies for the project... including the Java version Maven is attempting to use for the project.

Powerlord
  • 82,184
  • 16
  • 119
  • 164