VS Code即使构建失败仍会运行Java文件吗?

huangapple go评论69阅读模式
英文:

VS Code still runs Java file even when build fails?

问题

以下是您的翻译:

简单的问题这是我的Java文件

public class Test {

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

  void a() {
    qweifjew;
  }
}

当我在VS Code上按下运行它会显示构建失败是否要继续?”这很合理因为我有编译时错误但是当我继续按下时它仍然能够运行并显示It ran!”。为什么

有关运行命令的更多信息

C:\Users\jeffe\coding-tutorials\learning-jest> cd c:\Users\jeffe\coding-tutorials\learning-jest && c:\Users\jeffe\.vscode\extensions\vscjava.vscode-java-debug-0.27.1\scripts\launcher.bat "C:\Program Files\Java\jdk-11.0.2\bin\java.exe" -Dfile.encoding=UTF-8 -cp C:\Users\jeffe\AppData\Roaming\Code\User\workspaceStorage\5e0a770d0910238b624ead6f98bca1ec\redhat.java\jdt_ws\learning-jest_f8aabfb2\bin Test
It ran!
英文:

Simple question here. Here is my Java file:

public class Test {

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

  void a() {
    qweifjew;
  }
}

When I press "Run" on VS Code, it says build failed do you want to continue? Makes sense since I have compile-time errors. But when I press continue, it is still able to run and display "It ran!". How come?

For more information on the run command:

C:\Users\jeffe\coding-tutorials\learning-jest> cd c:\Users\jeffe\coding-tutorials\learning-jest && c:\Users\jeffe\.vscode\extensions\vscjava.vscode-java-debug-0.27.1\scripts\launcher.bat "C:\Program Files\Java\jdk-11.0.2\bin\java.exe" -Dfile.encoding=UTF-8 -cp C:\Users\jeffe\AppData\Roaming\Code\User\workspaceStoragee0a770d0910238b624ead6f98bca1ec\redhat.java\jdt_ws\learning-jest_f8aabfb2\bin Test
It ran!

答案1

得分: 1

这是您的代码的反编译后的 .class 文件:

public class Test {
    public Test() {
    }

    public static void main(String[] args) {
        System.out.println("It ran!ddfseffe");
    }

    void a() {
        throw new Error("Unresolved compilation problems: \n\tSyntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n\tqweifjew cannot be resolved\n");
    }
}
英文:

This is the decompiled .class file of your code:

public class Test {
    public Test() {
    }

    public static void main(String[] args) {
        System.out.println("It ran!ddfseffe");
    }

    void a() {
        throw new Error("Unresolved compilation problems: \n\tSyntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n\tqweifjew cannot be resolved\n");
    }
}

答案2

得分: 0

你在VS Code中是否开启了自动保存功能?
它可以运行先前成功构建的代码以提供输出。

英文:

You have Auto Save ON in VS code ?
It's able to run a previous successful build to give you an output.

huangapple
  • 本文由 发表于 2020年8月1日 16:09:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/63203119.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定