Why javac looks for .java extensions in filenames.
While java doesn’t look for .class in its argument? And goes to the .class file by itself automatically?
Is there any reason for this?
Why javac looks for .java extensions in filenames. While java doesn’t look for .class
Share
There’s no automatic adding of
.class: you just runjavaspecifying which class to use as main. The details of classloading and classpath are on a different level of abstraction: it is possible that there’s no.classfile, or e.g. it’s in a JAR.If you look closer, by the way, you’ll find that
javadoes not ask you for a path: there are no slashes (or, worse yet, backslashes) in the parameters, only the proper dots separating package names. So it’s never a “file.”javac, on the other hand, does indeed work with files, hence you need to specify those.