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

后端 未结 12 1668
广开言路
广开言路 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:55

    In case your Java class is in some package. Suppose your Java class named ABC.java is present in com.hello.programs, then you need to run it with the package name.

    Compile it in the usual way:

    C:\SimpleJavaProject\src\com\hello\programs > javac ABC.java
    

    But to run it, you need to give the package name and then your java class name:

    C:\SimpleJavaProject\src > java com.hello.programs.ABC
    

提交回复
热议问题