15

First of all, I'd like to point out that I am aware that this question has been asked countless times and I am aware of the usual solution. However, it doesn't seem to work for me.

When the error Exception in thread "main" java.lang.UnsupportedClassVersionError: org/telegram/mtproto/state/ConnectionInfo : Unsupported major.minor version 52.0 occurs, it is generally caused by compiling with an incompatible JDK-JRE combination. However, as shown by the images below, my setup seems to be in order:

Fig. 1. JDK Compliance

Fig. 1. JDK Compliance

Fig. 2. JRE Setting

Fig. 2. JRE Setting

Fig. 3. Java Home

Fig. 3. Java Home

What seems to be the problem? What am I missing? I'm using Eclipse Luna, trying to run some Telegram API Layer 11 code (the code works I reckon, as it was used by others).

brain56
  • 2,659
  • 9
  • 38
  • 70
  • 1
    Are you running the code from the command line or from within Eclipse? If it's from Eclipse, what does your run configuration look like? If it's from the command line, check your `PATH` environment variable. – Jon Skeet May 13 '14 at 06:25
  • Hi, @JonSkeet. Thanks for the interest in my question. I'm running from Eclipse. I don't know what my run configuration looks like. How do I get there? – brain56 May 13 '14 at 06:26
  • @brain56 What happens if you try switching to Java 7 and back? Or have you tried that already? – awksp May 13 '14 at 06:27
  • @user3580294, I already tried it, and that's where the problem started because the error explicitly states that it needs version 52.0 -- and that's Java 8. – brain56 May 13 '14 at 06:29
  • 1
    `Right click on app -> Run As -> Run configurations -> JRE Tab`. Set the JRE to current JRE availabe in your system. – Ravinder Reddy May 13 '14 at 06:29
  • @brain56 I meant both compiler and JRE, if your code allows it. – awksp May 13 '14 at 06:30
  • @brain56 Perhaps check project-specific settings too? – awksp May 13 '14 at 06:31
  • Ravinder or @JonSkeet I have +15 for you. :) It was set to jre7 in its run configuration. I set it to jre8 and it worked. Please post an answer. :) – brain56 May 13 '14 at 06:31
  • This [link](http://javarevisited.blogspot.sg/2015/05/fixing-unsupported-majorminor-version.html) all the details. – Abhijeet Nov 02 '15 at 10:45

2 Answers2

28

The JAVA_HOME environment variable is irrelevant to how Eclipse will run code, as far as I'm aware. Likewise the compiler settings you've shown for a project don't affect how code is run.

Instead, you need to look at the Run Configuration you're using when you run it, and check the environment there. Make sure you're using Java 8, and all should be well. Click on the triangle next to the Run button, and select "Run Configurations..." to open the dialog with all the settings. Then look at the JRE tab, and ensure you're using the right JRE.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
0

i see that you have a 32bits JDK version for the JDK 1.8 and a 64bits version for the JDK 1.7 i you running your project on a 64bits machine try to use the 64bits version of JDK 1.8 Note: you must have a 64bits version for eclipse too

Fakher
  • 2,098
  • 3
  • 29
  • 45