是否可以将Java.net.http与Vscode一起使用& Java扩展插件?
我正在与他人合作,并正在使用Visual Studio代码进行Java项目。由于我们仅共享源.java
文件,因此我不知道如何从其他导入Java.net.http模块的其他代码运行代码。当VScode报告问题时,我应该如何运行代码?
编辑:javac-version
给出Javac 1.8.0_332,这可能是问题所在。 复制的步骤:
- 打开一个文件夹
- 创建Java文件
- 导入Java.net.http.httpclient;
- 错误:“导入java.net.http无法解决”
I am collaborating with others and am using Visual Studio Code for doing the Java projects. As we are only sharing the source .java
files only, I have no idea on how to run the code from others that imports java.net.http module. How should I run the code as VSCode is reporting problems?
Edit: javac --version
gives javac 1.8.0_332 which might be the problem.
Steps to reproduce:
- open a folder
- create a java file
- import java.net.http.HttpClient;
- error: "The import java.net.http cannot be resolved"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
如Andrewjames所述,
java.net.http
在Java版本11中介绍了命令Palette(Ctrl+Shift+P)下的JDK -17的设置VS代码 - Java:配置Java Runtime解决问题。 。您可能需要从在线下载JDK 11+安装程序。参考: https://code.visualstudio.com/docs/docs/java/java/java/ java-project#_configure-jdk
As mentioned by andrewJames,
java.net.http
was introduced in Java version 11. Setup VS Code with JDK-17 under Command Palette (Ctrl+Shift+P) - Java: Configure Java Runtime resolve the issue. You might need to download JDK 11+ installer from online.Reference: https://code.visualstudio.com/docs/java/java-project#_configure-jdk