While compiling java files through cmd (ie through javac command) it is written as filename.java but to run the same program we write filename and don't add the extension. Why is extension removed in java command or extension added in javac command ? Any specific reason.
When compiling, you specify the name of one or more source files, thus the .java extension
When running you specify the class name of the main class, thus no extension.
The difference becomes even more apparent, when the class is in a package:
javac mypackage/MyClass.java
java mypackage.MyClass