How do I run a Java program from the command line on Windows?

后端 未结 12 1839
广开言路
广开言路 2020-11-22 03:03

I\'m trying to execute a Java program from the command line in Windows. Here is my code:

import java.io.File;
import java.io.FileInputStream;
import java.io.         


        
12条回答
  •  忘掉有多难
    2020-11-22 03:51

    Since Java 11, java command line tool has been able to run a single-file source-code directly. e.g.

    java HelloWorld.java
    

    This was an enhancement with JEP 330: https://openjdk.java.net/jeps/330

    For the details of the usage and the limitations, see the manual of your Java implementation such as one provided by Oracle: https://docs.oracle.com/en/java/javase/11/tools/java.html

提交回复
热议问题