我目前正在学习 Java 课程,并且正在使用 VSCode。我写了以下代码:
class Simple{
public static void main(String args[]){
System.out.println("Hello World!");
} }
但问题是每次我运行代码时都会出现一条消息:
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS D:\Visual Studio Code\Java Practice> & 'c:\Users\user\.vscode\extensions\vscjava.vscode-java-debug-0.26.0\scripts\launcher.bat' 'ripts\launcher.bat' 'C:\Users\user\AppData\Local\Programs\AdoptOpenJDK\bin\java.exe' '-Dfile.encoding=UTF-8' '-cData\Roaming\Code\Usep' 'C:\Users\user\AppData\Roaming\Code\User\workspaceStorage\3be13cab7faa4596286e209d09d9be11\redhat.java\jdt_ws\Java Practice_fb59611a\bin' 'Simple' Hello World! PS D:\Visual Studio Code\Java Practice>
我只想看到我的输出,在本例中是“Hello World!”。有没有办法删除其他行?
答案1
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"args": "",
"console": "internalConsole",
"mainClass": "${file}"
},
]
}
将其添加到您的launch.json
文件中。这里对您来说重要的选项是"console": "internalConsole",
这将输出所有内容到调试控制台标签而不是终端。它看起来会像这样干净。