Applets are constructed differently from applications, and they also have some security barriers in place to prevent harm to the user's computer (these restrictions can be applied to applications as well, but usually aren't).
Your applet needs to extend java.awt.Applet or javax.swing.JApplet, depending on your preferred toolkit. Instead of main(), various event-driven functions such as public void start(), public void init() are used, and obviously the only way to interact with the user is through a GUI (which you can paint onto the Applet or JApplet in the same way you'd use a Panel or JPanel) since there is no console available in the browser.
The default restrictions are mostly obvious things, like not being able to access the filesystem, but there are some less blatant ones as well, such as not being able to call System.exit(). Opening new Frames is allowed, but the frames will have a label somewhere on them saying "Java Applet Window."