microsoft / vscode-gradle

Manage Gradle Projects, run Gradle tasks and provide better Gradle file authoring experience in VS Code
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle
MIT License
127 stars 53 forks source link

Build server error when running in WSL with JDK 8 #1628

Open tudortimi opened 1 day ago

tudortimi commented 1 day ago

Extension Name: vscode-gradle Extension Version: v3.16.4 OS Version: Ubuntu 20.04.6 LTS in WSL VSCode version: 1.95.2 JDK version: 8

Describe the bug

I'm getting the following error message when trying to run in VS Code with remote connection to WSL:

No connection to gradle server. Try restarting the server.

Opening the "Gradle for Java" output, I see:

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/github/badsyntax/gradle/GradleServer 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 52.0

I'm using JDK 8, but the code seems to be compiled for JDK 15.

Strangely enough, even if I disable the build server in settings, I still get this error.

Expected behavior

The extension says it should work with Java version between 8 and 21.

Output from "Gradle for Java"

See the description.

Does the bug still exist if you disable all other extensions? Yes

jdneo commented 1 day ago

Could you share your vscode settings?

tudortimi commented 1 day ago

For the Gradle extension, I'm using the defaults, in both Windows and in WSL:

Image Image

tudortimi commented 1 day ago

While looking at extensions, I noticed that the redhat.java extension wasn't installed in WSL, only in Windows. After installing it in WSL as well, the build server started working:

Image

It's using it's own JRE, though, which is at version 15. Is this expected? Also, it would have been nicer if VS Code would have told me explicitly that I also need the Java extension in WSL, because it's required by the Gradle extension.