Why don't we use the .class extension with "java" command? -


why don't give filename.class file after java command, instead of filename?

suppose want compile test.java program, run javac test.java. ok!

after produce test.class file run program run java test instead of java test.class. reason this?

because not describing file run. telling java class contains main method - , class' name (in case) filename, not filename.class.

the fact bytecode contained in files on filesystem implementation detail. classpath pass java command tells where classes, , main class argument tells class use.

(it's different javac, because program take source files , compiles them bytecode.)


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -