-1

Getting exception while executing written code. Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. I have written below code and that is showing error Java Version- 1.8 enter image description here

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

  • You are not using Java1.8, check what compiler has been referenced in your eclipse project. Looks like you are using 1.4. Finally, don't upload the error message as an image, post it as plain text in your question. – Barney Feb 22 '18 at 05:04

2 Answers2

0

As you mentioned you are using JDK v1.8 the same is not reflected in the screenshot you provided. As per the screenshot j2sdk1.4.2_10 is getting detected. Hence you see the error as :

java.lang.UnsupportedClassVersionError: (Unsupported major.minor version 50.0)

A simple solution would be to remove/uninstall the old JDK version completely from your system and download the latest JDK v8u162 and add to your Project in the IDE and recompile your program and execute it.

Additionally, you may require to set your Compiler Compliance Level to 1.8 in your IDE and this can be done in the Preferences settings of your IDE for example in Eclipse go to Windows -> Preferences then select Java and expand it then select Compiler and change the compliance level to 1.8

Here you can find a detailed discussion Unsupported major.minor version 52.0 [duplicate]

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Major minor version error happen when you have JRE in Java build path instead of JDK. MajorMinorIssue You have to follow below steps.

  1. Right click on project in the eclipse and go to properties.
  2. Click on Java-Build path.
  3. Go to library section.
  4. If JRE/JDK section is absent in Library section then click on Add Library otherwise select JRE and click edit.
  5. Install JRE -> Add -> Select JDK installed path and Finish.
  6. Select the JDK checkBox in Installed JRE and click ok.
  7. Select JDK in JRE System Library.

Hope this will solve your problem.

Pradeep hebbar
  • 2,147
  • 1
  • 9
  • 14