Examples are from "Thinking in Java".
import static net.mindview.util.Print.*; class Art { Art() { print("Art constructor"); } } class Drawing extends Art { Drawing() { print("Drawing constructor"); } } public class Cartoon extends Drawing { public Cartoon() { print("Cartoon constructor"); } public static void main(String[] args) { Cartoon x = new Cartoon(); } }
Then I compile and run:
michael@michael:~/Downloads/thinking_in_java/TIJ4-code-master/examples/reusing$ javac -cp /home/michael/Downloads/thinking_in_java/TIJ4-code-master/examples Cartoon.java michael@michael:~/Downloads/thinking_in_java/TIJ4-code-master/examples/reusing$ java -cp /home/michael/Downloads/thinking_in_java/TIJ4-code-master/examples:. Cartoon.java error: can't find main(String[]) method in class: Art
The question is: Why is it looking for main class in the Art class? And how to make it run the main method in Cartoon class?