-2

Well my pc has only JDK 20 installed but whenever i try to run any program requiring java runtime it fails saying it cant recognize files above 55.0 ( tried with flutter, minecraft and few more). Screenshot of the error

There is also only a single path to java in my environment variables and i can confirm its version to be 20 by running java -version in cmd. As far as i know jre comes within jdk or do i have to install both seperately? Someone pls help.

These are my results from cmd:

C:\Users\yvviv>flutter doctor --android-licenses Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 Android sdkmanager tool was found, but failed to run (C:\Users\yvviv\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\sdkmanager.bat): "exited code 1". Try re-installing or updating your Android SDK, visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

C:\Users\yvviv>java -version java version "20.0.2" 2023-07-18 Java(TM) SE Runtime Environment (build 20.0.2+9-78) Java HotSpot(TM) 64-Bit Server VM (build 20.0.2+9-78, mixed mode, sharing)

Also JAVA_HOME is set

Vivek Y V
  • 3
  • 2
  • How are you trying to run the java program? Can you post screenshot of when you run java -version? – ashish.g Aug 21 '23 at 10:57
  • How are you running those programs? If your `java -version` says that it's v20, but you get those errors, then you're not running them with that Java version. Instead you seem to have [JDK](https://stackoverflow.com/q/9170832/2541560) 11 at least. – Kayaman Aug 21 '23 at 10:58
  • is `JAVA_HOME` set? – Lesiak Aug 21 '23 at 11:01
  • 1
    `flutter` is probably misinformed. You could try `set JAVA_HOME="";flutter doctor --android-licenses` btw [Please never post images of text](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557). They are not searchable, we cannot copy-paste... Always copy-paste the text and format it properly. Please learn how to copy-paste with cmd.exe – g00se Aug 21 '23 at 11:05
  • That should have said *set JAVA_HOME="";flutter doctor --android-licenses* but to give it the best chance, do `set JAVA_HOME="";set PATH="%JAVA_HOME\bin;%PATH%";flutter doctor --android-licenses` and if that works for you, you can set those values permanently – g00se Aug 21 '23 at 11:17

1 Answers1

0

You must be compiling and running with different Java versions. Some applications can come with a bundled JRE and Java can also be installed in a lot of different locations. So you have to make sure that you are really using the version you want. Check your environment variables again, especially the JAVA_HOME and PATH variables. If there is another JRE earlier in the PATH variable it will be used instead of any later matches. So you can move up the java you want to use to the first position of the PATH.

Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60