Compiling and executing a java program

Compiling and executing a java program is done in the command prompt in Windows.

Compiling a program
javac file_name.java
Executing a java program
java class_name
javac : The java compiler.
file_name : Name of the file with which the java program is saved. The file should be saved with a .java extension.

java : The java interpreter.
class_name : Name of the class in which the main() is written.

Note : When a class is declared public, the class name and the file name should be matched.

No comments: