Visual Studio 无法正确运行我的代码 [英] Visual Studio doesn't run my code properly

查看:211
本文介绍了Visual Studio 无法正确运行我的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 代码为学校编写 Java,它运行我的代码真的很奇怪.所以发生的事情是,我的代码,应该只是使用超级简单的System.out.println"打印出test",在终端中与所有使用的目录的列表一起运行,它真的是无组织的.这是它的样子:

I'm using Visual Studio code to write Java for school, and it runs my code really weird. So what happens is that my code, which is supposed to just print out "test" using super simple "System.out.println", runs in the terminal along with a list of all the directories used and it is really unorganized. This is what it looks like:

PS C:\Users*myname*\Documents\Java\java_with_vscode> &'C:\Users*myname*.vscode\extensions\vscjava.vscode-java-debug-0.21.0\scripts\launcher.bat''C:\Program Files\AdoptOpenJDK\jdk-11.0.4.11-hotspot\bin\java' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users*myname*\AppData\Roaming\Code\User\workspaceStorage\0e6931a1b8b4239719709a0414b75a46\redhat.java\jdt_ws\java_0a6'HelloBin'测试PS C:\Users*myname*\Documents\Java\java_with_vscode>

PS C:\Users*myname*\Documents\Java\java_with_vscode> & 'C:\Users*myname*.vscode\extensions\vscjava.vscode-java-debug-0.21.0\scripts\launcher.bat' 'C:\Program Files\AdoptOpenJDK\jdk-11.0.4.11-hotspot\bin\java' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users*myname*\AppData\Roaming\Code\User\workspaceStorage\0e6931a1b8b4239719709a0414b75a46\redhat.java\jdt_ws\java_with_vscode_e672b01a\bin' 'Hello' test PS C:\Users*myname*\Documents\Java\java_with_vscode>

所以代码在巨大的文本块之后显示出来,并且它也适用于我之前测试过的用户输入,但我知道事实上这不是它应该如何显示的.我观看了 Youtube 视频,对于每个人,他们的代码都显示在调试控制台中,而对我来说,我的调试控制台是空的.输出选项卡也是空的,当我在输出或调试控制台上选择时,它只会自动在终端中运行代码.我不确定为什么会发生这种情况,并且在网上搜索了几个小时也没有帮助,这要么是我独有的问题,要么是我脑残,错过了一个非常简单的步骤.无论哪种情况,我都会很感激一些帮助.如何使我的代码在调试控制台中显示出来,而不是在终端中显示?

So the code chows up after the huge blob of text, and it also works with user input as I tested before but I know for a fact this isn't how it is supposed to be displayed. I watched Youtube videos and for everyone, their code shows up in debug console, and for me my debug console is empty. The output tab is also empty, and when im either selected on output or debug console, it just automatically runs the code in the terminal. I am unsure why this happens, and searching for hours online didn't help, either this a problem unique to me or I'm being braindead and missing a really simple step. Either case, I would appreciate some help. How do I make it so that my code shows up in debug console how it is supposed to rather than in the terminal?

感谢您抽出宝贵时间.

我已经从 Ninite 和官方网站重新下载了 Visual Studio.

I have redownloaded Visual Studio from Ninite and the official website.

我添加了 Java 路径.

I have added Java paths.

我已使用 Java: quickstart 选项为项目创建文件,但仍然无法正常工作.

I have used the Java: quickstart option to make the files for a project and still doesn't work.

public class Hello {

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

推荐答案

在调试控制台中显示它应该如何而不是在终端

shows up in debug console how it is supposed to rather than in the terminal

尝试在 launch.json 中添加 "console": "internalConsole" ,例如:

try to add "console": "internalConsole" in your launch.json like :

"configurations": [
           {
             "type": "java",
             "name": "CodeLens (Launch) - App",
             "request": "launch",
             "mainClass": "com.test.maven.App",
             "console": "internalConsole",
             "projectName": "my.app"
           }
         ]

这篇关于Visual Studio 无法正确运行我的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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