Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't start client Java Language Server #270

Open
n1nja88888 opened this issue Aug 26, 2023 · 2 comments
Open

Couldn't start client Java Language Server #270

n1nja88888 opened this issue Aug 26, 2023 · 2 comments

Comments

@n1nja88888
Copy link

OS: Windows10
Version: 0.2.46

I just installed this extension in VS Code and then I ran into this error. Did I miss out on something? Are there any prerequisites before installing this extension?

@n1nja88888
Copy link
Author

The output as follows:
Error: spawn UNKNOWN
at ChildProcess.spawn (node:internal/child_process:441:11)
at Object.spawn (node:child_process:752:9)
at c:\Users\N1NJA88888.vscode\extensions\georgewfraser.vscode-javac-0.2.46\node_modules\vscode-languageclient\lib\main.js:357:40

@grimly
Copy link

grimly commented Sep 15, 2023

Hello,

Some more information on this issue that I share :

The extension try to run %USERPROFILE%\.vscode\extensions\georgewfraser.vscode-javac-0.2.46\dist\lang_server_windows.sh

Of course, starting a shell script in Windows may only crash. I understand this is something about WSL. Here is the code to blame : https://github.com/georgewfraser/java-language-server/blob/master/lib/extension.ts#L327-L328

For an immediate fix, change the file %USERPROFILE%\.vscode\extensions\georgewfraser.vscode-javac-0.2.46\out\lib\extension.js at line 300+ :

  function platformSpecificLangServer() {
      switch (process.platform) {
          case 'win32':
-             return ['dist', 'lang_server_windows.sh'];
+             return ['dist', 'lang_server_windows.cmd'];
          case 'darwin':
              return ['dist', 'lang_server_mac.sh'];
          case 'linux':
              return ['dist', 'lang_server_linux.sh'];
      }
      throw `unsupported platform: ${process.platform}`;
  }

Once that changed. I'm running into an other issue, Java 17 is not enough :

java.lang.UnsupportedClassVersionError: org/javacs/Main has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 61.0

It requires at least Java 18.
This is unfortunate at this very moment but a new LTS is comming soon so I won't mind for now.
The current documentation states Java 13

If someone has the knowledge to detect if the user is either using plain windows or WSL, your input on this platformSpecificLangServer function is most welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants