Nadir Laskar Nadir Laskar - 17 days ago 7
Java Question

Class not found error while running class in java

filename: Demo.java

public class Demo extends DemoLast{
public static void main(String[] args){
new Demo().message();
}
}


class DemoLast{
public void message(){
System.out.println("Hello from Last");
}
}


On Executing:

javac Demo.java
java Demo



Error: Could not find or load main class Demo.class


I am unable to run this code above. It compiles properly but on execution, it says class not found error.

Why is it not running?

Directory has only Single file,

F:
-- Packaging
-- Demo.java

Answer

It isn't finding the correct path run it with:

java -classpath . Demo 
Comments