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)?
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)?
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').
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.
© 2022 - 2024 — McMap. All rights reserved.