Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 

Help is available for each task, or you can go straight to the solution source code.



Task 1

Import Netscape's security package to provide access to the capabilities API.


import netscape.security.*;

Task 2

At the beginning of the block of code that does the word counting, in the getCount method of the skeleton code, enable the appropriate privilege for accessing any network connection.


The name of the privilege is UniversalConnect.
PrivilegeManager.enablePrivilege ("UniversalConnect");

Task 3

At the end of the block of code, disable the same privilege.


If you forget to disable the privilege, the program could attempt to access a network connection from a place where it should not be privileged.
PrivilegeManager.revertPrivilege ("UniversalConnect");

Task 4

In the popupMessage method, enable the appropriate privilege for disabling the applet warning message for dialogs.


The name of the privilege is UniversalTopLevelWindow.
PrivilegeManager.enablePrivilege (
  "UniversalTopLevelWindow");

Task 5

After the source code for creating the dialog, disable the privilege.


PrivilegeManager.revertPrivilege (
  "UniversalTopLevelWindow");

Task 6

Add Netscape's capabilities classes to your CLASSPATH.


If you place the classes in the same directory as you compile, the following command will add the package to the end of your CLASSPATH.
set CLASSPATH=
  %CLASSPATH%;capsapi_classes.zip

Task 7

Compile the program.


javac WordCount.java

Task 8

Create an HTML loader for the applet.


<applet code=WordCount width=300 height=100>
</applet>

Task 9

Load program into Communicator and try it out.


Counting words takes time. You can comment out the print statement in the source to print each word as it is counted.
Copyright © 1998 MageLang Institute. All Rights Reserved.

[ This page was updated: 16-Nov-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.