Download the JDK
Search the Tutorials
Hide the TOC
Trail: Deployment
Lesson: Applets
Section: Getting Started with Applets
Applets
Getting Started with Applets
Importing Classes and Packages for Applets
Defining an Applet Subclass
The Life Cycle of an Applet
Methods for Milestones
Methods for Drawing and Event Handling
Methods for Adding UI Components
What Applets Can and Can't Do
Taking Advantage of the Applet API
Finding and Loading Data Files
Displaying Short Status Strings
Displaying Documents in the Browser
Sending Messages to Other Applets
Playing Sounds
Defining and Using Applet Parameters
Deciding Which Parameters to Support
Writing the Code to Support Parameters
Giving Information about Parameters
Using the APPLET Tag
Practical Considerations When Writing Applets
Security Restrictions
Creating a User Interface
Creating a GUI
Displaying Diagnostics to the Standard Output and Error Streams
Getting System Properties
Threads in Applets
Threads in Applets: Examples
Working with a Server-Side Application
A Simple Network Client Applet
Using a Server to Work Around Security Restrictions
Finishing an Applet
Before You Ship that Applet
The Perfectly Finished Applet
Deploying Applets
General Deployment Considerations
Using the applet Tag
Using the object Tag
Using the embed Tag
Deploying Applets in a Mixed-Browser Environment
Solving Common Applet Problems
Questions and Exercises
Home Page > Deployment > Applets
« Previous • Trail • Next »
What Applets Can and Can't Do

> This page gives an overview of both the restrictions applets face and the special capabilities they have. You'll find more details in the Security Restrictions section.

### Security Restrictions

> Every browser implements security policies to keep applets from compromising system security. This section describes the security policies that current browsers adhere to. However, the implementation of the security policies differs from browser to browser. Also, security policies are subject to change. For example, if a browser is developed for use only in trusted environments, then its security policies will likely be much more lax than those described here.

> Current browsers impose the following restrictions on any applet that is loaded over the network:

> - An applet cannot load libraries or define native methods.
> - It cannot ordinarily read or write files on the host that's executing it.
> - It cannot make network connections except to the host that it came from.
> - It cannot start any program on the host that's executing it.
> - It cannot read certain system properties.
> - Windows that an applet brings up look different than windows that an application brings up.
> Each browser has a `SecurityManager` object that implements its security policies. When a `SecurityManager` detects a violation, it throws a `SecurityException`. Your applet can catch this `SecurityException` and react appropriately.

### Applet Capabilities

> The `java.applet` package provides an API that gives applets some capabilities that applications do not have.

> Here are some other things that current browers and other applet viewers let applets do:

> - Applets can usually make network connections to the host they came from.
> - Applets running within a Web browser can easily cause HTML documents to be displayed.
> - Applets can invoke public methods of other applets on the same page.
> - Applets that are loaded from the local file system (from a directory in the user's `CLASSPATH`) have none of the restrictions that applets loaded over the network do.

« Previous • Trail • Next »
Previous page: Methods for Adding UI Components
Next page: Taking Advantage of the Applet API