For some reason I cannot run my compiled .class file via cmd command .. java myFile. It throws "Error: Could not find or load main class" Then I've made a very simple Hello.java file which just prints Hello, compiled it to Hello.class and it worked no problem. I don't get it why is one instance running fine while other throws error? They're both in same dirrectory, they were both compiled same way. When running the program from Eclipse it works fine.. here is the code:
public class Human {
Human() {
System.out.println("Boy called Human");
};
public void walk() {
System.out.println("Human walks");
}
static class Boy extends Human {
Boy() {
super();
}
Boy(String name) {
System.out.println("Constructor with arg called");
}
public void walk() {
System.out.println("Boy walks");
}
public static void main(String args[]) {
// Reference is of parent class
Human myobj = new Boy();
myobj.walk();
Human myobj2 = new Human();
myobj2.walk();
}
}
}