简体   繁体   English

无法用vscode运行Java程序

[英]Unable to run Java program with vscode

I have upgraded my Visual Studio Code to version details:我已将我的 Visual Studio Code 升级到版本详细信息:

Version : 1.38.1 (user setup)版本:1.38.1(用户设置)
Commit : b37e54c98e1a74ba89e03073e5a3761284e3ffb0提交:b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date : 2019-09-11T13:35:15.005Z日期:2019-09-11T13:35:15.005Z
Electron : 4.2.10 Electron :4.2.10
Chrome : 69.0.3497.128:69.0.3497.128
Node.js : 10.11.0 Node.js :10.11.0
V8 : 6.9.427.31-electron.0 V8 :6.9.427.31-电子.0
OS : Windows_NT x64 10.0.18362操作系统:Windows_NT x64 10.0.18362

Every time I run the simple HelloWorld program written in Java, vscode prompt the following error每次运行Java写的简单HelloWorld程序,vscode提示如下错误

Extension host terminated unexpectedly扩展主机意外终止

I think some extension related to Debugger of Java is incompatible with the vscode version or it may be deprecated.我认为与 Java 的调试器相关的某些扩展与 vscode 版本不兼容,或者可能已被弃用。

问题

Any help will be appreciate, Thanks任何帮助将不胜感激,谢谢

Did you install jdk?你安装了jdk吗? Are you using visual studio code?您使用的是 Visual Studio 代码吗? If yes then do this:如果是,请执行以下操作:

Please install necessary extensions and add an extension that create a.class file to excecute that.java file or you can simply use cmd请安装必要的扩展并添加一个扩展来创建一个.class文件来执行那个.java文件或者你可以简单地使用cmd

In cmd goto your file location and enter following在 cmd 中转到您的文件位置并输入以下内容

  1. javac filename.java (this creates a.class file) then enter javac filename.java (这将创建一个.class文件)然后输入
  2. java filename.java (you will see your output in cmd) java filename.java (您将在 cmd 中看到您的 output)

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

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