Running basic java programs from commands line is a 3 steps process:
Write code:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } }
Compile by
javac HellWorld.java
which would check for errors & generateHelloWorld.class
file.run code by giving the class name -->
java HelloWorld
Now, I am curious to know why:
java HelloWorld
works but when we give fullpath of the classfile, it throws an error
$ java HelloWorld.class
Error: Could not find or load main class HelloWorld.class
What does it make a difference if we give just the classname Vs classname with file-extension?