Why are you deleting .class when running on the JVM?

Example: I have the source code, FooBar.java

 javac FooBar.java 

which gives me FooBar.class .

Why does the JVM command line API accept FooBar instead of FooBar.class (works with UNIX FYI)?

+8
java jvm jvm-arguments
source share
2 answers

This is just a convention! Classes are loaded using their fully qualified class name. ClassLoader then knows how to map class names to file names (for example, by adding ".class").

+5
source share

Just because you need to tell the JVM the name of the class you want to run, and not its actual file name. Another example: if your class was myPackage / FooBar.java, you would compile myPackage / FooBar.class, although you would put myPackage.FooBar as a jvm argument.

+4
source share

All Articles