Home » Java Basics » 07 - A Simple GUI Application with Thread Management
Screenshot 7c: The Appletviewer Command
7
Running Applets Using the 'appletviewer' command
How to run applets using the 'appletviewer' command
- Open a blank file in notepad and copy the following single line into it:
<applet code=ShowFruits width=250 height=250></applet>
- Click on File -> Save.
- Browse the 'MySamples\build\classes' subfolder next to 'Save in:'
Important:Select 'All Files' next to Save as Type
- Enter 'ShowFruits.htm' next to 'File Name' and hit save. Close the file.
- 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.
- 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;
};
- Click on File -> Save.
- Browse to the 'MySamples' subfolder next to 'Save in:'
Important:Select 'All Files' next to Save as Type
- Enter 'applet.policy' next to 'File Name' and hit save. Close the file.
- Click on the Windows Start Menu at the bottom left hand side of the screen.
- 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 )
- 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