Starting a class in Java, but different

The difference is that your first example uses Applet technology, which is now widely deprecated. The browser will run it for you inside a JVM which it creates.

A Java applet is a special kind of Java program that a browser enabled
with Java technology can download from the internet and run. An applet
is typically embedded inside a web page and runs in the context of a
browser. An applet must be a subclass of the java.applet.Applet class.
The Applet class provides the standard interface between the applet
and the browser environment.

Your second example is a Java application designed to be invoked directly by the JVM. Command line arguments will be passed as a String array into main(). i.e.

java -cp . org.example.FirstApp

Leave a Comment