简体   繁体   English

无法让 Java 在 Visual Studio Code 中工作

[英]Can't get Java to work in Visual Studio Code

I've been trying to install java on vs code for a couple hours now and I can't seem to get it to work.我已经尝试在 vs code 上安装 java 几个小时了,但我似乎无法让它工作。 I've already downloaded all the extensions necessary and I've downloaded the coding pack from https://code.visualstudio.com/docs/languages/java for windows (I'm on windows 11).我已经下载了所有必要的扩展,并从https://code.visualstudio.com/docs/languages/java下载了 windows 的编码包(我在 windows 11)。 According to multiple tutorials, this is all I should have to do, but when I make a test.java file, the "run java" does nothing and "run code" gives me an error.根据多个教程,这就是我应该做的,但是当我创建一个 test.java 文件时,“run java”什么都不做,“run code”给我一个错误。

代码

and this is the output when I click that run button in the top right:当我单击右上角的运行按钮时,这是 output: 输出

Does anybody have any suggestions?有人有什么建议吗? the coding pack was supposed to come with a jdk, its working for everybody else so I'm not sure what the issue is.编码包应该与 jdk 一起提供,它适用于其他所有人,所以我不确定问题出在哪里。

It seems like you don't have correctly installed java sdk on your system.看来您没有在系统上正确安装java sdk

Try to check java sdk installation with following commands:尝试使用以下命令检查java sdk安装:

java --version
javac --version

In case you don't see reasonable output, try to install java sdk , go to the Java Downloads section of the Oracle website, and download the Installer from there.如果您看不到合理的 output,请尝试将java sdk和 go 安装到 Oracle 网站的 Java 下载部分,然后从那里下载安装程序。

Are you sure you are following the documentation?您确定您正在关注文档吗? It looks like you didn't download the official Java extension pack, but used Code Runner to run the code.貌似你没有下载官方的Java扩展包,而是用Code Runner运行代码。

Please download the Java extension package and use Run Java or Run to run the code.请下载Java 扩展 package并使用Run JavaRun来运行代码。

在此处输入图像描述

Getting Started with Java in VS Code. VS Code 入门 Java。

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

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