Currently a beginner to Java
and I have the extension Code Runner
installed. I am able to run my code within the window via the Run | Debug
options provided by Code Runner
. However, after compiling the file with javac
, I am unable to run the file. This is the basic code inside a filepath CommandLineApp/HelloWorld.java
.
package CommandLineApp;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world..!!!");
}
}
After I cd
into CommandLineApp, I ran
javac HelloWorld.java
java HelloWorld
which gives me this error
Error: Could not find or load main class HelloWorld
Caused by: java.lang.NoClassDefFoundError: CommandLineApp/HelloWorld (wrong name: HelloWorld)
Apologies if this is a really simple question!