Reputation:
Example: I have some source code, FooBar.java
javac FooBar.java
that gives me FooBar.class
.
Why does the JVM command line API take FooBar
instead of FooBar.class
(working on UNIX FYI)?
Upvotes: 8
Views: 239
Reputation: 1428
Just because you have to tell the JVM the name of the class you want to run, not its actual filename. Another example, if your class was myPackage/FooBar.java you would compile to myPackage/FooBar.class, though you would put myPackage.FooBar as jvm argument.
Upvotes: 4
Reputation: 24454
That's just a convention! Classes are loaded using their fully qualified class name. The ClassLoader
then knows how to map class names to file names (e.g. by appending '.class').
Upvotes: 5