You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error message in VS Code (Source: Spring Boot Tools (Extension)):
Spring Tools Language Server requires Java 11 or higher to be launched. Current Java /opt/java/17.0.1/bin/java. (Note Java 8 can still be used in your own projects. Java 11 is only required to launch the Spring Tools Language Server process)
The version check that causes the above error message uses the output of java -XshowSettings:properties to identify the Java version (java.version property), so it might be interesting to see the output of this for the JDK mentioned in the above error message (from within a terminal in the Codespaces workspace).
I'm in the browser (local VSCode with Codespaces never seems to work for me). Here's the output from that command. It's weird because it doesn't use /opt/java/17.0.1/jdk at all. So that setting is coming from somewhere?
The output from the vscode-spring-boot-debug-log is here:
Activating 'vscode-spring-boot' extension
"spring-boot.ls.java.home" setting not specified or empty value
"java.home" setting not specified or empty value
No user specified java-home setting. Looking for JAVA_HOME env variable...
found JVM at location "/opt/java/17.0.1/jre" is not a JDK
Trying to find JDK corresping to currently found JRE. Checking for JDK at /opt/java/17.0.1/jdk
Found java executable: /opt/java/17.0.1/bin/java
$ /opt/java/17.0.1/bin/java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)
Why is there a JDK 1.8.0 under the 17.0.1 path? Really strange setup from Codespaces, but it at least explains why the Spring Boot extension complains about the JDK it tries to use is not a JDK >= 11... ;-)
Maybe this is related to the project being defined for a compilation level of Java 1.8 and the Java tooling tries to be smart about this, but this is just guessing...
So that's where it comes from, but AFAIK it's nothing to do with me. I just open the project in the browser.
Yeah, understand, I can reproduce this in a browser using Codespaces as well. I guess you just opened the Codespaces workspace for the project and then installed the Java Extension Pack as well as the Spring Boot Extension Pack into this Codespaces workspace, right?
You could fix this problem by specifying the JDK location for the Spring Boot extension in the preferences via: spring-boot.ls.java.home and then set this to the JDK that Codespaces uses a current: /home/codespace/.java/current/bin/java (which would be the JDK11 in your case).
It's completely baffling. I opened a support ticket with Github but I'm not sure that can be public. I opened a public issue here: microsoft/vscode-dev-containers#1245 as well.
I tend to close this issue as a duplicate of the one you mentioned above. We could theoretically change the logic of how the extension tries to find the right JDK to somehow deal with this situation, but since there is a JAVA_HOME specified that the extension tries to use (as a last resort before checking specific preferences), I think we should leave it the way it is. Okay?
I guess. It seems like JAVA_HOME could easily point to the wrong version anyway, even without this stupid codespaces issue. It might be good to be able to look in other well known locations as well, before failing.
look for the Spring Boot extension specific preference (spring-boot.ls.java.home)
look for the Java Language Extension preference for the JDK (java.home)
look for the JAVA_HOME env variable
look for the PATH env variable
The problem might be that the check for the JDK >= 11 happens after this strategy found a JDK (from top to bottom), it does not continue the search if one of the found JDKs is < 11. In your case it looks like the first two options are not set, then JAVA_HOME is found pointing to a JDK and is used, but then recognized as JDK < 11.
So we could improve the strategy to continue the search if the found JDK is not >= 11 as well as add additional locations to the list of searched locations. WDYT?
Activity
BoykoAlex commentedon Jan 6, 2022
Tried Oracle Java 17 - it worked fine.
Which Java 17 did you install?
dsyer commentedon Jan 6, 2022
I just opened a random project in codespaces, so whatever that gives you, I guess. I might have asked for Java 17 explicitly but I don’t recall.
martinlippert commentedon Jan 10, 2022
I have tried this one here (https://github.com/martinlippert/codespaces-spring-test2) with a JDK17, that seems to work when I open that in Codespaces in a browser window. Can you share the random project where you observe this issue? And did you open Codespaces in a browser or via your local VSCode?
The version check that causes the above error message uses the output of
java -XshowSettings:propertiesto identify the Java version (java.versionproperty), so it might be interesting to see the output of this for the JDK mentioned in the above error message (from within a terminal in the Codespaces workspace).dsyer commentedon Jan 10, 2022
I'm in the browser (local VSCode with Codespaces never seems to work for me). Here's the output from that command. It's weird because it doesn't use
/opt/java/17.0.1/jdkat all. So that setting is coming from somewhere?The output from the vscode-spring-boot-debug-log is here:
and in a terminal:
and
So that's where it comes from, but AFAIK it's nothing to do with me. I just open the project in the browser.
The project I opened was this one: https://github.com/xmolecules/jmolecules-integrations (but the problem is not unique to that repository).
martinlippert commentedon Jan 10, 2022
This one is really strange:
Why is there a JDK 1.8.0 under the
17.0.1path? Really strange setup from Codespaces, but it at least explains why the Spring Boot extension complains about the JDK it tries to use is not a JDK >= 11... ;-)Maybe this is related to the project being defined for a compilation level of Java 1.8 and the Java tooling tries to be smart about this, but this is just guessing...
Yeah, understand, I can reproduce this in a browser using Codespaces as well. I guess you just opened the Codespaces workspace for the project and then installed the Java Extension Pack as well as the Spring Boot Extension Pack into this Codespaces workspace, right?
You could fix this problem by specifying the JDK location for the Spring Boot extension in the preferences via:
spring-boot.ls.java.homeand then set this to the JDK that Codespaces uses a current:/home/codespace/.java/current/bin/java(which would be the JDK11 in your case).dsyer commentedon Jan 10, 2022
It's completely baffling. I opened a support ticket with Github but I'm not sure that can be public. I opened a public issue here: microsoft/vscode-dev-containers#1245 as well.
martinlippert commentedon Jan 10, 2022
I tend to close this issue as a duplicate of the one you mentioned above. We could theoretically change the logic of how the extension tries to find the right JDK to somehow deal with this situation, but since there is a JAVA_HOME specified that the extension tries to use (as a last resort before checking specific preferences), I think we should leave it the way it is. Okay?
dsyer commentedon Jan 10, 2022
I guess. It seems like
JAVA_HOMEcould easily point to the wrong version anyway, even without this stupid codespaces issue. It might be good to be able to look in other well known locations as well, before failing.martinlippert commentedon Jan 10, 2022
This is the strategy that the extension uses:
spring-boot.ls.java.home)java.home)JAVA_HOMEenv variablePATHenv variableThe problem might be that the check for the JDK >= 11 happens after this strategy found a JDK (from top to bottom), it does not continue the search if one of the found JDKs is < 11. In your case it looks like the first two options are not set, then
JAVA_HOMEis found pointing to a JDK and is used, but then recognized as JDK < 11.So we could improve the strategy to continue the search if the found JDK is not >= 11 as well as add additional locations to the list of searched locations. WDYT?
BoykoAlex commentedon Jan 17, 2022
Think it might be fixed indirectly while fixing #715
BoykoAlex commentedon Feb 14, 2022
Should be fixed in the latest vscode extension
martinlippert commentedon Feb 15, 2022
@dsyer Any feedback from the Codespaces team about the wrong JDK appearing on the JDK17 path?