vscode-java: Version 1.2.0 doesn't detect JDK installed via Homebrew well
I’ve been using the extension for some time now. A couple of days ago, I’ve updated it to 1.2.0 and since then, when opening a study project it would report errors for everything.
Some of the errors include not finding Object
’s default no args constructor, failing to import basic core classes from Java (i.e. java.util
, java.date
), and so on.
I’ve already removed my JDK 17 installation, replacing it with JDK 11, and that had no effect. Only fix I’ve found is to rollback the extension to the previous version (1.1.0, from 3w ago).
Some screenshots are attached to show the errors I’m facing.
Environment
- Operating System: macOS 12.1 Monterey arm64 (Apple Silicon)
- JDK version: openjdk version “17.0.1” 2021-10-19, installed via Homebrew
- Visual Studio Code version: 1.63.2 (Universal)
- Java extension version: 1.2.0
Steps To Reproduce
- Clone example project
- Open project folder in VS Code
- Open any .java file
Example project: https://github.com/brunovieira97/alura-novidades-java
Logs: Logs.zip
Current Result
Expected Result (v1.1.0)
Additional Informations
- Reinstalling the extension had no effect
- Tried removing VS Code completely and reinstalling as well
- As previously stated, I removed
openjdk
via brew and installedopenjdk@11
, properly linking it. No effect at all - Log for "Language Support for Java (Syntax Server) shows this message, both with 1.1.0 and 1.2.0:
[Error - 13:29:00] Connection to server got closed. Server will not be restarted.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (7 by maintainers)
@testforstephen was able to test today and it’s working as expected now. Thank you for fixing this so fast, everyone!
Homebrew creates a lot of symbolic links, I find we can only rely on
<some-path>/bin/java
, which is finally linked to the real installation location.I’ve covered this case in latest jdk-utils. If you have a NodeJS runtime, you can run below command to test if your installed JDK is detected.
Below is my smoke test.
UPDATE
I just find on https://docs.brew.sh/Installation, location of homebrew is different per platform.
/usr/local
for macOS Intel, covered in jdk-utils@0.4.1./opt/homebrew
for Apple Silicon, which is @brunovieira97 's case./home/linuxbrew/.linuxbrew
for Linux. Later I’ll cover all above cases in jdk-utils, and create a PR then.Could you try the following:
@brunovieira97 https://download.jboss.org/jbosstools/jdt.ls/staging/java-1.3.0-491/ has fixed this issue, pls try to download the new extension version java-darwin-arm64-1.3.0-491.vsix for Apple M1, and manually install the vsix to VS Code.
@Eskibear This is a new corner case that the new findJavaHome lib
jdk-utils
needs to cover better. https://github.com/Eskibear/node-jdk-utils/issues/2I can’t reproduce it. Could you try the latest build - https://download.jboss.org/jbosstools/jdt.ls/staging/java-1.3.0-490/java-1.3.0-490.vsix