Accessing Native methods from a Java Applet

http://www.ebsolutech.com

 

by Sanket Bakshi, s.bakshi@ebsolutech.com

 

 

Previous section: Overview

Normal Applet Capabilities

1.      Applet Capabilities

2.      Security Restrictions

Applet Capabilities

The applet is a Java code that has a capability to embed itself into a HTML page. The applet life cycle starts when the page in which it is embedded is loaded. An applet is created by extending the Applet class in the java. Applet package.

The java.applet package provides an API that gives applets some capabilities that applications don't have.

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

o       Applets can usually make network connections to the host they came from.

o       Applets running within a Web browser can easily cause HTML documents to be displayed.

o       Applets can invoke public methods of other applets on the same page.

o       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.

o       Although most applets stop running once you leave their page, they don't have to.

o       The applets can also incorporate into themselves a dynamic GUI.

Security Restrictions

Every browser implements security policies to keep applets from compromising system security. 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:

o       An applet cannot load libraries or define native methods.

o       It cannot ordinarily read or write files on the host that's executing it.

o       It cannot make network connections except to the host that it came from.

o       It cannot start any program on the host that's executing it.

o       It cannot read certain system properties.

o       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.

 

 

Next section: The JNI Technology
 
Table of Contents

 


Top of Page | Home


© 2001 – EBSolute Technologies