Java Applet runs without a main method?
Solution 1
Java Applets have an init method instead of main. It's:
public void init() {... }
Solution 2
Yes, but applets aren't applications. There is a main method in the applet runner (assuming it's implemented in Java; it need not be) but the applet doesn't work that way; it gets loaded/instantiated from a file and then it proceeds along its lifecycle through initialization, starting, operating, stopping, and finally being destroyed. The code that sends it through these states is hidden from the applet's view; it just knows its in an environment that can run applets.
Solution 3
Applets differ from stand-alone Java applications in that they do not need to implement a main method.
Nicholas Kong
Updated on June 12, 2022Comments
-
Nicholas Kong about 2 years
I was running a Java class that
extends Applet implements Runnable
and apparently the program can run, but there is nomain
method. I thought Java applications needs themain
method as its entry point? -
Nicholas Kong over 12 yearsOh okay so applets use init and applications uses main. Thanks everyone!