vscode-java: Extension version 1.22.0 cannot find OpenJDK on macOS
Compiling or running Java code using version 1.22.0 of the extension on macOS 13.5 (Apple Silicon) using VSCode 1.82.1 and OpenJDK Temurin-17.0.8.1+1 results in errors, including the following, suggesting that the JDK cannot be found:
The project was not built since its build path is incomplete.
Cannot find the class file for java.lang.Object.
This is resolved by downgrading to version 1.21.0 of the extension.
Environment
- Operating System: macOS 13.5 (Apple Silicon)
- JDK version: OpenJDK Temurin-17.0.8.1+1
- Visual Studio Code version: 1.82.1
- Java extension version: 1.22.0
Steps To Reproduce
- Reproduced inside a new macOS 13 install running in a virtual machine.
- Install VSCode 1.82.1
- Install Extension Pack for Java (Includes current ‘Language Support for Java by Red Hat’, version 1.22.0)
- Install VSCode suggested JVM (OpenJDK Temurin-17.0.8.1+1)
- Create a HelloWorld.java file
- Various compiler errors shown in VSCode.
- Downgrade ‘Language Support for Java by Red Hat’ plugin from 1.22.0 to 1.21.0
- Reload VSCode
- HelloWorld.java code now compiles and runs.
[Please attach a sample project reproducing the error]
public class HelloWorld {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 8
- Comments: 25 (2 by maintainers)
We’ve released 1.22.1, fixing this issue, to the marketplace. Please make sure you update. If you still see JDK class errors after upgrading to 1.22.1, please open Command Palette and run “Java: Clean Java Language Server Workspace”.
There’s a new pre-release in the VS Code & OpenVSX marketplaces for a
1.23.2023091313
pre-release. Could those affected (@Pfeil , @pgraug , @plastr ) try it out and let us know whether that fixes this issue ?If you don’t want to go through the pre-release UI in VS Code, assuming you’re either on
darwin-x64
ordarwin-arm64
, VS Code Marketplace provides a direct link to the vsix through the “Version History” tab :Alternate links :
Related on Stack Overflow: Why is my build path suddenly incomplete for my java project in VS Code?, where I have written up an answer post.
You are correct - I was not within a statement block. It works fine on 1.23 😃
Version 1.23.2023091313 of the extension resolves the issue for me. Thank you!
@fbricon thanks! I updated my answer on Stack Overflow with the info you just gave 😃
@rgrunber it works to me. thank you for helping us
I found a way to reproduce the issue yesterday, and tried
v1.23.2023091313
today, the issue is fixed now.@berriesaregreat We moved a lot of snippets (like
sout
) to the server side so the language server would only activate them where it made sense. How are you usingsout
? One of the differences is that it will no longer show up unless you are within a statement block. So it wouldn’t show up if you’re just within a type declaration.Hi. Same Here. Mac M2, Ventura 13.5.2, Vscode 1.82.1 , amazon-corretto-17.jdk. downgrading to 1.21 resolved all issues, me too.
➜ ~ npm i jdk-utils && npx jdk-utils
up to date, audited 2 packages in 357ms
found 0 vulnerabilities Listing JDKs: 41.111ms Found: 2 [ { homedir: ‘/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home’, hasJavac: true, version: { java_version: ‘17.0.8.1’, major: 17 } }, { homedir: ‘/usr’, isInPathEnv: true, hasJavac: true, version: { java_version: ‘17.0.8.1’, major: 17 } } ]
Chiming in late, but downgrading to 1.21 resolved all issues for me; going to 1.23.2023091313 fixed it too but it also broke shortcuts such as sout (the prompt to expand it to system.out doesn’t show up). Thanks!
Confirmed: