Nadir Laskar Nadir Laskar - 1 year ago 113
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

Answer Source

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

java -classpath . Demo 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download