My JAVA Programs used to run without any errors on both the Terminal and Visual Studio Code's Terminal.
After my Mac updated to MacOs Big Sur Version 11.0.1, my JAVA programs show an error, even though the same code worked properly before.
There was no error before.
I checked my JDK and JRE Installations also
My Python files execute normally in the VS Code environment, so I do not think there is a problem with VS Code.
I have tried searching for an solution and have tried to clear the logs.
I would appreciate if anyone could guide me:)
Run the .java file in Terminal to check if JDK can work normally:
javac Hey.java java Hey
If there's nothing wrong with the above command execution, turn to VS Code, uninstall Java Extension Pack and also delete the related folders under User/name/.vscode/extensions
, then reinstall it again;
Set java.home
and java.configuration.runtimes
in User Settings.json.
Reference: Configure JDK .
Then run the project again to see if the problem goes away.
您需要在 VS Code 中安装 java 插件。
Install Java by searching for extensions in VSCode and try to run again.It will be executed. I belive it is not installed
Hi just found a solution here! Initially guess it should be a problem with zsh. so first open your terminal and type
open ~/.zshrc
at this point you will see text editor pops up with a zsh config file.
Add
export JAVA_HOME=`/usr/libexec/java_home
to the last line in that file, and save the file quit.
Then just reopen the VSC and you will notice everything would back to normal as usual.
I faced a similar problem. When running the same Java program, it worked in terminal but VS Code couldn't detect java.
All it turned out to be was I forgot to add Code itself to Path after reinstallation, nothing to do with Java.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.