简体   繁体   English

为什么尝试在 vs 代码中运行 java 时会出现此错误?

[英]Why this error occurs while trying to run java in vs code?

I'm trying to use vs code for java.我正在尝试将 vs 代码用于 java。 but get this error while running the code I tried to find the solution but I couldn't find, If any solution available please refer:但是在运行代码时出现此错误我试图找到解决方案但我找不到,如果有任何可用的解决方案,请参考:错误

In a nutshell, you have not installed Java correctly.简而言之,您没有正确安装 Java。 Finalizing the installation of Java on Windows requires some manual steps.在 Windows 上完成 Java 的安装需要一些手动步骤。 You must always perform these steps after installing Java, including after upgrading the JDK.您必须始终在安装 Java 之后执行这些步骤,包括在升级 JDK 之后。

  1. Find the Java path;找到Java路径; it looks like this: C:\Program Files\Java\jdkxxxx\bin\它看起来像这样:C:\Program Files\Java\jdkxxxx\bin\
  2. Start-menu search for "environment variable" to open the options dialog.开始菜单搜索“环境变量”以打开选项对话框。
  3. Examine PATH.检查路径。 Remove old Java paths.删除旧的 Java 路径。
  4. Add the new Java path to PATH.将新的 Java 路径添加到 PATH。
  5. Edit JAVA_HOME.编辑 JAVA_HOME。
  6. Close and re-open console/IDE.关闭并重新打开控制台/IDE。

Add the jdk path to your windows system environment.将 jdk 路径添加到您的 windows 系统环境。

Then in your VS code workspace settings add the path too.然后在您的 VS 代码工作区设置中也添加路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM