VS 代码在 TERMINAL 而不是 OUTPUT 中显示打印输出 [英] VS code shows print output in TERMINAL instead of OUTPUT

查看:30
本文介绍了VS 代码在 TERMINAL 而不是 OUTPUT 中显示打印输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Java 编程设置 VS 代码,我已经完成了.然而,有一件事特别困扰我.例如,当我运行下面的代码时,我会在 TERMINAL 选项卡中获得输出以及许多我不想看到的其他垃圾.如何更改它以便控制台中唯一的输出是测试..."?

I'm trying to set up VS code for java programming, and I'm kind of done. However one thing in particular bothers me. When I for example run the code below I get the output in the TERMINAL tab along with a lot of other junk that I don't want to see. How can I change it so that the only output is "Testing..." in the console?

public class Hello{
    public static void main(String[] args){
        System.out.println("Testing...");
    }
}

我运行代码后的输出如下图所示.即使我点击其他选项卡,它们也是空的,即使我删除/隐藏终端选项卡,每次我重新运行代码时,它都会弹出.

The output after I run the code is shown in the figure below. Even if I click on the other tabs, they are empty and even if I remove/hide the terminal tab, each time I re-run the code it pops up regardless.

推荐答案

{
    // 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", 这会将所有内容输出到 调试控制台 选项卡而不是终端.它看起来会像这样干净.

Add this to your launch.json file. The important option for you here is "console": "internalConsole", This will output everything to the Debug Console tab and not terminal. And it will look clean like this.

这篇关于VS 代码在 TERMINAL 而不是 OUTPUT 中显示打印输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆