package demo;
import java.io.*;
class A
{
public void run()
{
System.out.println("This Is Class A : public void run()");
}
}
class B
{
public static void main(String args[])
{
System.out.println("Main Method Executed");
A obj1 = new A();
obj1.run();
}
}
Compile :
d:\java>javac -d . demo.java
---> class file be created in directory demo [ A.class, B.class]
Run : d:\java>java B
Error: could not find or load main class B
but if I remove the line 1 [package demo;] than it run proper. so, when we use package name than why "Error: could not find or load main class B" error be generated.
java demo.A