Steps to compile a java program
Create your
.javasource fileName of the file should be same as class name (just a norm, works otherwise).
Compile your
.javasource file to generate a.classfilejavac -d <destination of .class files> sourcefile.java.classfile will have same name as class.javachere is java compiler.
Go to destination folder which contains
.classfile and run following command.java filenameActually filename will be f
ilename.classbut we write without.classjavahere is application launcher
Note that
jvmlooks forpublic static void main(String[] variable)and not the compiler.Hence, when you do not mention this main function and compile program, it does not give you compile-time error. But when you run it without main run-time error is obtained.
Last updated