Home » Java Basics » 07 - A Simple GUI Application with Thread Management
7

Running Applets Using the 'appletviewer' command

How to run applets using the 'appletviewer' command

  1. Open a blank file in notepad and copy the following single line into it:
     <applet code=ShowFruits width=250 height=250></applet>
  1. Click on File -> Save.
  2. Browse the 'MySamples\build\classes' subfolder next to 'Save in:'

Important:Select 'All Files' next to Save as Type

  1. Enter 'ShowFruits.htm' next to 'File Name' and hit save. Close the file.
  2. Now, go to the 'MySamples' subfolder and check if it contains a file named 'applet.policy'. This is a plain text file that contains the file permissions possessed by the applet on the local machine.
  3. If you cannot find the 'applet.policy' file in the MySamples subfolder, open a blank file in notepad and paste the following into it:
grant {
permission java.security.AllPermission;
};
  1. Click on File -> Save.
  2. Browse to the 'MySamples' subfolder next to 'Save in:'

Important:Select 'All Files' next to Save as Type

  1. Enter 'applet.policy' next to 'File Name' and hit save. Close the file.
  2. Click on the Windows Start Menu at the bottom left hand side of the screen.
  3. Click on Run. Enter 'cmd' next to 'Open:' in the Run pop up box and click on OK. Go to the MySamples\build\classes subfolder (this folder contains ShowFruits.class and our other sample classes )
  4. Issue the following command in the 'MySamples\build\classes' subfolder and hit the enter key (replace E:\JavaTutorial\info with the appropriate path on your computer and make sure there are no line breaks):
E:\JavaTutorial\info\MySamples\build\classes>appletviewer
-J-Djava.security.policy=e:\JavaTutorial\info\MySamples\applet.policy
ShowFruits.htm
Screenshot 7c: The Appletviewer Command
Screenshot 7c: The Appletviewer Command