Nadir Laskar Nadir Laskar - 4 months ago 36
Java Question

Class not found error while running class in 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:

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,

-- Packaging


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

java -classpath . Demo