Skip to main content

Unable to find HelpSet

3 replies [Last post]
lorenjerickson
Offline
Joined: 2003-10-16
Points: 0

Folks,
I am having trouble loading a HelpSet from a JAR file in my project. I've copied the code from the JH 2.0 users guide verbatim (adjusting for different help set and class names, of course):

String helpHS = "my help set.hs";
ClassLoader cl = MyClass.class.getClassLoader();
try {
URL hsURL = HelpSet.findHelpSet(cl, helpHS);
hs = new HelpSet(null, hsURL);
} catch (Exception ee) {
// Say what the exception really is
System.out.println( "HelpSet " + ee.getMessage());
System.out.println("HelpSet "+ helpHS +" not found")
return;
}

The problem is that the hsURL is always null. The only difference I can see is that the help set name has spaces in it as you can see above. Does anyone know if this is a problem? Seems like it might be since the class loader is involved. Thanks in advance for your responses.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pkeegan
Offline
Joined: 2005-06-10
Points: 0

As the trail of links in this message implies, replacing:

ClassLoader cl = MyClass.class.getClassLoader();
try {
URL hsURL = HelpSet.findHelpSet(cl, helpHS);

with

URL hsURL = getClass().getResource(helpHS);

works for me, where helpHS equals the fully-qualified path/name of the .hs file, e.g. "/com/acme/myapp/MyHelpSet.hs"

Can anybody tell me about any disadvantages of this approach? Is there something else I should be doing to make the findHelpSet() approach work?

I've tried approaches of having the help set packaged with the .class files and of having a separate .jar, but I got the "HelpSet Could not parse/Got an IOException (null)/Parsing failed for null each time.

shaoyun
Offline
Joined: 2005-05-17
Points: 0
shaoyun
Offline
Joined: 2005-05-17
Points: 0

I was straggling with the problem for quite a while and tried this solution below where findHelpset is not used. It works for me!

try {
ClassLoader c1 = this.class.getClassLoader();
URL hsURL = new URL("file:/c:/helpHS");
hs = new HelpSet(c1, hsURL);
} catch (Exception ee) {
// Say what the exception really is
System.out.println( "HelpSet " + ee.getMessage());
System.out.println("HelpSet "+ helpHS +" not found")
return;
}