how to fix this error: class file has wrong version 52.0, should be 49.0
The error message means that you try to load a Java 8 class with a Java 5 VM.
For an unknown reason $JAVA_HOME/bin/javac
is using the JDK 8 Java runtime (.../rt.jar
) but the compiler itself is loaded with a Java 5 VM.
My next step would be to make sure that $JAVA_HOME/bin/javac
is actually what it should be (and not a script which does something weird). I'd also check the environment (CLASSPATH
) and options like -Xbootclasspath
. Try set | grep -i java
and set | grep -i path
to look for suspicious variables.
If nothing seems to work, try to reinstall the Java 8 SDK again.
I had exactly the same issue with the same versions when trying to build the Arduino IDE using ant. The fix is to remove an old version of tools.jar from /Library/Java/Extensions/
- just wanted to clarify for others that hit the same issue.