Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

rosjava unsupported class version error

Hi everyone,

I have absolutely no idea what has gone wrong here. One day I have a perfectly working system using rosjava, and then the next morning I am getting this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ros/RosRun : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
Could not find the main class: org.ros.RosRun. Program will exit.

I haven't changed any code, updated any files, nothing. This just happened. Does anyone have any idea why?

Things I have tried: After doing research on errors similar to this, I found out that it occurs when java versions do not match. 51 is Java 1.7. So I checked out my own java version with:

java -version

and got:

java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-1ubuntu0.12.04)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

So I am running java 1.6. Makes sense, the error is telling me RosRun is 1.7. Let me check.

$ file RosRun.class 
RosRun.class: compiled Java class data, version 50.0 (Java 1.6)

Well thats not the case. That means my code must be compiling in 1.7. Let me check:

$ file project/build/classes/main/com/github/hsmrs_gui/project/GuiNode.class 
project/build/classes/main/com/github/hsmrs_gui/project/GuiNode.class: compiled Java class data, version 50.0 (Java 1.6)

I'm at a loss. Can anyone help?