“VSCode ‘java’ 未被识别为内部或外部命令、可操作的程序或批处理文件。”

huangapple go评论91阅读模式
英文:

VSCode 'java' is not recognized as an internal or external command, operable program or batch file

问题

如标题所述,在我尝试在VSCode终端中运行Java命令时,出现以下错误:

"'java' 不被识别为内部或外部命令,可操作的程序或批处理文件。"

然而,在我正常的Windows命令提示符(CMD)中可以运行这些命令,所以我不明白为什么在VSCode中无法工作。

我已将Java的bin路径添加到了PATH环境变量中。

提前感谢! “VSCode ‘java’ 未被识别为内部或外部命令、可操作的程序或批处理文件。”

英文:

As the title says, I get the following error when I try to run Java commands in the VSCode terminal:

'java' is not recognized as an internal or external command, operable program or batch file.

However, I am able to run these commands in my normal windows CMD, so I don't understand why it doesn't work in VSCode.

I have added the java bin path to the PATH environment variable.

Thanks in advance! “VSCode ‘java’ 未被识别为内部或外部命令、可操作的程序或批处理文件。”

答案1

得分: 1

我曾经遇到过同样的问题。我分享一下我的经验,也许对你有帮助。

1- 首先,你可以为 VS Code 安装 Java 扩展包,你可以很容易地搜索到它,在 VS Code 的扩展中找到它,然后选择一个安装。

2- 另一个棘手的问题是,如果你在 VS Code 中使用终端,在更改了环境变量或安装新的扩展后,最好重新启动计算机,然后打开 VS Code,关闭当前的终端选项卡,然后打开一个新的选项卡,再次尝试 java -version 命令。

问候。

英文:

I had the same problem. I share my experience it may work for you.

1- Firstly, you can install java package extension for VS Code, you can search it easily, find it in the extension in VS Code, and choose one of them to install.

2- Another tricky thing happened for me is that, if you use terminals in VS Code, after changing environmental variables or installing new extension, it's better to restart the computer, then open the VS Code, kill the current terminal tab and open a new one and try the java -version command again.

Regards

huangapple
  • 本文由 发表于 2020年10月20日 20:35:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/64445297.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定