Reputation: 333
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 :)
Upvotes: 2
Views: 4251
Reputation: 89
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.
Upvotes: 0
Reputation: 1
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.
Upvotes: 0
Reputation: 9521
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.
Upvotes: 2
Reputation: 40
Install Java by searching for extensions in VSCode and try to run again.It will be executed. I belive it is not installed
Upvotes: 0