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

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

    It is easy. If you have saved your file as A.text first thing you should do is save it as A.java. Now it is a Java file.

    Now you need to open cmd and set path to you A.java file before compile it. you can refer this for that.

    Then you can compile your file using command

    javac A.java

    Then run it using

    java A

    So that is how you compile and run a java program in cmd. You can also go through these material that is Java in depth lessons. Lot of things you need to understand in Java is covered there for beginners.

提交回复
热议问题