class file has wrong version 52.0

Hello all! I have been trying to deploy code to this year’s robot but have been receiving an error when I attempt to do so. The compiler spits this out every time:

Buildfile: /Users/324876/Documents/workspace/Tank Drive/build.xml
Trying to override old definition of task classloader
   [delete] Deleting directory /Users/324876/Documents/workspace/Tank Drive/build
    [mkdir] Created dir: /Users/324876/Documents/workspace/Tank Drive/build
     [echo] [athena-compile] Compiling src with classpath=/Users/324876/wpilib/java/current/lib/WPILib.jar:/Users/324876/wpilib/java/current/lib/NetworkTables.jar: to build
    [javac] Compiling 1 source file to /Users/324876/Documents/workspace/Tank Drive/build
    [javac] /Users/324876/Documents/workspace/Tank Drive/src/org/usfirst/frc/team4301/robot/ cannot access edu.wpi.first.wpilibj.SampleRobot
    [javac] bad class file: edu/wpi/first/wpilibj/SampleRobot.class(edu/wpi/first/wpilibj:SampleRobot.class)
    [javac] class file has wrong version 52.0, should be 50.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    [javac] import edu.wpi.first.wpilibj.SampleRobot;
    [javac]                             ^

/Users/324876/wpilib/java/current/ant/build.xml:71: Compile failed; see the compiler error output for details.

Total time: 2 seconds

It is just one of the example programs, so I know that there is not a problem with my code. Has anybody seen this before? What should I do to fix it?

Check your java version (on both the laptop and roboRIO) - if WPILib was compiled with a different version than you deployed to your roboRIO or have on your laptop, it can cause issues. Usually I see this (doing other projects) when trying to run a jar and getting a “wrong major/minor version” error.

I believe the numbers correspond to java versions as:

J2SE 8 = 52
J2SE 7 = 51
J2SE 6.0 = 50
J2SE 5.0 = 49
JDK 1.4 = 48
JDK 1.3 = 47
JDK 1.2 = 46
JDK 1.1 = 45

Which would mean it was built on Java 8, but you’re trying to run it on Java 6.

I have updated the JDK on my laptop and the JRE on the roboRIO to Java 8u71. The compiler is still giving me the same error. It is also telling me that “the hierarchy of the type Robot is inconsistent.”

Did you update in eclipse as well? The eclipse project points to a specific java jdk, and won’t update itself. right click on the project, go to properties, then java build path, libraries, and remove the java library and add the new one (you may have to click through the screens to find it and add it to eclipse itself).