简体   繁体   English

为什么我需要使用 javac 来编译我的代码?

[英]Why do i need to use javac to compile my code?

Let's say i have a code like this:假设我有这样的代码:

public class Test {
    public static void main(String args[])
    {
        int x = 5;
        // Widening Casting
        double myNum = x;
        System.out.println(x + " " + myNum);
    }
}

Now i write the following commands in powershell changing the value of x from 5 to 6 once in my code and saving it, it works perfectly fine.现在我在 powershell 中编写以下命令,在我的代码中将 x 的值从 5 更改为 6 一次并保存它,它工作得很好。 But tutorials online suggest me to use javac for compilation.但是网上的教程建议我使用 javac 进行编译。 Why so?为什么这样?

在此处输入图像描述

From Java 11 onwards, the java command is able to compile and run a single Java source file with a static void main(String[]) entry point method. From Java 11 onwards, the java command is able to compile and run a single Java source file with a static void main(String[]) entry point method. (This feature was added as JEP 330 .) (此功能已作为JEP 330添加。)

The online tutorials are correct for Java 10 and earlier, and they are correct for cases where more than one Java source file needs to be compiled.在线教程适用于 Java 10 及更早版本,适用于需要编译多个 Java 源文件的情况。

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

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