javac - java file compilation with file extension -


when compile java program use javac file.java command while running use java file.

so why necessary explicitly specify file extension while compiling , not needed when run java program?

because when "run" java .class compiled file telling java application launcher class contains main method. launcher starts java runtime environment , loads specified class.

if write java myclass, class main method myclass. note erroneous write java myclass.class, since myclass.class not name of class.

when compile javac myclass.java need tell java compiler extension, because file , need find it.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -