There's no automatic adding of .class
: you just run java
specifying 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 .class
file, or e.g. it's in a JAR.
If you look closer, by the way, you'll find that java
does 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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…