In this CommandLineApplet example You can see an applet program run from command Line without using any web browser.
import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class CommandLineApplet extends Applet { public static void main(String[] args) { Frame ComApplet = new Frame("Applet from Command Line"); ComApplet.setSize(350, 250); Applet CommandLineApplet = new CommandLineApplet(); ComApplet.add(CommandLineApplet); ComApplet.setVisible(true); ComApplet.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public void paint(Graphics g) { g.setFont(new Font("Arial",Font.BOLD,14)); g.drawString("Applet from Command Line", 100, 100); } }
Compiling Applets:
Javac CommandLineApplet.java
Running Applet from console:
java CommandLineApplet