Using help sets in a Java application
To use help sets in a Java application, the classes of the JavaHelp runtime extension need to be available to the application. This can be accomplished by placing the JavaHelp runtime extension into the extensions directory of the JRE ( <JRE>/lib/ext) or to make the JavaHelp runtime extension available in the classpath.
Displaying help in an application
A common way to display help from within an application is to
This will display the common help set viewer for respective help set.
Specifying the help set to be viewed
To create a HelpSet object, you must specify the help set, that should be viewed. This is done with a URL that is passed to the constructor of the HelpSet object. As there are two ways, a help set can be stored, there can be two forms of a URL too.
Uncompressed help set file
If the help set file is stored uncompressed along with the other files belonging to the JavaHelp help set, the URL would be file:/<path to help set directory>/<help set name>.hs
Example : file:/c:/programs/myapp/myappHelp.hs
Compressed help set file
If the help set is stored compressed in a Java Archive file (JAR), the URL would be jar:file:/<path to help set directory>/<archive name>.jar!/<help set name>.hs
Example : jar:file:/c:/programs/myapp/myapp.jar!/myappHelp.hs
Code Example
The following Java code example documents, how a help set can be called directly from out of an application.
try {
URL hsUrl = new URL("jar:file:/c:/programs/myapp/myapp.jar!/myappHelp.hs");
HelpSet hs = new HelpSet(null, hsUrl);
HelpBroker hb = hs.createHelpBroker();
hb.setDisplayed(true);
}
catch (Exception e) {
System.out.println("HelpSet could not be opened");
}
See also