0

I am getting an error while running the Java code.

It is always showing me:

Unsupported major.minor version 52.0 in java

On my system, the version of Java is Java 7 but by default it is taking the version Java 8.

I don't know why it is taking the Java 8 version because I have Java 7 on my system.

Please help me to getting out of this error.

Thanks in advance.

Jayesh Vyas
  • 1,145
  • 3
  • 15
  • 35
  • If you have Mac - then system has it's own java. So you could have two versions at the same time: system version and user's version. – Oleg Cherednik Nov 27 '17 at 07:16
  • If you want java7 to be used, ensure that JAVA_HOME is pointing to java 7 path and PATH has bin folder of jdk7. Looks like your javac -version is 1.8.xxx – Bharanidharan K Nov 27 '17 at 07:16

2 Answers2

2

Its because of Java version mismatch.Just need to double check your system environment variable JDK_HOME and JRE_HOME point to JAVA 1.7 as well.

You must run and compile your application with the same version of Java.

If you're using Eclipse you should do 2 things:

In Eclipse, click on "Window > Preferences", and in the window that appears, on the left side, under "Java", click on "Installed JREs", click on "Add..." and navigate to the folder that contains the JDK. Right-click on your project and click on "Properties", in the window that appears, on the left side, click on "Java Compiler" and uncheck "Use compliance from execution environment on the Java Build Path", this allows you to choose in the the list "Compiler compilance level" the same version that you set in the previous step.

Hope that helps.

Akshay
  • 1,161
  • 1
  • 12
  • 33
2

This is because On your system javac utility is pointing to Java 1.8 but java utility is pointing to Java 1.7.

To resolve it do following:

Note: I'm assuming that you are working on Windows OS.

  • In PATH variable, remove the very first path, if it looks like ...\Oracal\javapath
  • Set JDK_HOME and JRE_HOME for Java 1.7
cse
  • 4,066
  • 2
  • 20
  • 37