Introduction to JavaHelp

concepcionsockSoftware and s/w Development

Aug 15, 2012 (5 years and 10 months ago)


Presented By:

What is JavaHelp:

Most software developers do not look forward to spending time
documenting and explaining their product.

JavaSoft has developed the JavaHelp API: a full
featured, platform
independent, extensible help system that gives developers and authors
the ability to efficiently incorporate an online help system into
applications (both network and stand
alone), applets, JavaBean
components, HTML pages, operating systems, and devices.

To use JavaHelp in an application we need to prepare a set of files
described below. With the exception of

files and
h files,
each file is expected to be in the XML format.

For more information about XML see

1) Java Help API

2) HelpSet File

contains Helpset.hs

3) Map File

contains Map.jhm

4) Table of Contents(TOC) File (XML)

5) Index File (XML)

6) Help Content files.

7) Search Files( Database files)

JavaHelp Configuration Files:

What needs to be done:

Download and extract the JavaHelp API to the C:> , from

Set up the path for the java indexer used for making a
search database for the content files


Edit the java run time environment in your IDE( Eclipse,
Netbeans or BlueJ, to include the java help api bin files…).

Start Coding

HelpSet File

contains layout.hs

HelpSet file allows JavaHelp to
locate the configuration files for the
different views.

It also stores the location of the
map file which is used to map the
content files to ID tags used in
context sensitive help.

Layout of the HelpSet file.

Map File

contains layout.jhm

The map file is used to
map the content files to the
ID tags.

ID tags are used in
context specific help and
allow for abstraction of
content file urls.

Map file layout.

Table of Contents(TOC) File (XML)

TOC represents a view
that typically contains
references to help topic
IDs in a logically grouped

Layout of TOC file

Index File (XML)

Index view is very similar
to a TOC view described
before, but typically
organizes references to help
topics in alphabetical order.

Layout of the index
configuration file.

Content Files

JavaHelp content files are stored in the HTML format.

We can use one or more content files.

The files can be stored locally or on a server.

The map file stores the IDs and the URLs of the content files.

Search Files( Database files)

The search view allows users to search
through the content files for specific

Every instance of the keyword is
highlighted in the content files where they
are present.

Jhindexer: jhindexer is a utility which
catalogs all the keywords found in the
content files.

Running the indexer

from the root
directory of the project, at the command
prompt type:

JavaHelpSearch directory is created

Now Lets look at what to code

You will be Surprised to know that using this
API cuts down the number of lines of code to less
than 20.

Here is how you use the API and start coding

HelpSet Class

This class represents a collection of help information files we
discussed above: HelpSet, table of contents (TOC), index,
content, and map files.

To create a HelpSet instance we must supply two parameters: a
ClassLoader instance used to locate any classes required by the
navigators in the help set, and the URL of the main HelpSet file.

The following code shows a typical HelpSet instantiation,
assuming the main HelpSet file, helpset.hs, is contained in the
current running directory:

ClassLoader loader = this.getClass().getClassLoader();

URL url = HelpSet.findHelpSet(loader, “helpset.hs");

HelpSet hs = new HelpSet(loader, url);

The HelpBroker interface

This interface describes a component used to manage the
presentation and interaction with a HelpSet.

We can use the HelpSet.createHelpBroker() method to
retrieve an instance of HelpBroker.

We can then use HelpBroker’s enableHelpKey() method,
specifying the String ID of a desired help topic, to enable
JavaHelp on a given Component.

HelpBroker hb = hs.createHelpBroker();

hb.enableHelpKey(myFrame.getRootPane(), "MyTopicID", hs);

The Map interface

This interface defines a String ID to URL mapping.

The inner class Map.ID is used to identify a help topic. It
encapsulates a HelpSet reference / String ID pair.

Given an ID we can get the associated URL and vice
versa. Each HelpSet has an associated Map instance.

JHelp Class

This class represents the main JavaHelp viewer capable of
displaying help set data using JTree or JList navigators in a
JTabbedPane, and a content viewer (normally a JEditorPane
for HTML display).

The current implementation of JavaHelp does not provide
public access to this class via HelpSet or HelpBroker

You can do a lot more to customize your help viewers and
add neat features such as context sensitive help etc.

Customize your Help Application

It is really easy to customize your application by using the
classes offered by the API, Such as

HelpModel interface

:It maintains IDs and URLs corresponding to
the HelpSet being displayed


: navigation control (JTree or JList) for the GUI
presentation of help topic data


: context sensitive help


: user objects in a navigational view’s JTree or JList.

HelpModelListener interface

: listener which receives when the current help topic is