I faced a rather strange problem while executing a java program from the command line on Windows.
I used this command to create a source.class file from a source.java file.
javac source.java
After this, I tried to execute the source.class file using:
java source.class
This gave me the following error:
Error: Could not find or load main class source.class
However, when I do this:
java source
I get the output as desired.
I am curious to know why it failed when I mentioned .class explicitly. My professor told me that the java command is associated with .class files. Thus I want to know why this happened. Thank you.
EDIT: I don't believe this is a duplicate. I have already read the linked question. I am asking why the java command cannot execute a file when I mention .class explicitly.