findHelpSet return a null URL while integrating JavaHelp system inside my application using Eclipse

943 views Asked by At

I'm trying to include JavaHelp inside my application developed under Eclipse.

I did the following things:

  1. Download and extract the JavaHelp library in a sub-folder of my project workspace.
  2. Added the following library's JARs to my project class path (Properties->Java Build Path->Libraries->Add External JARs):

    jh.jar

    jhall.jar

    jhbasic.jar

    jsearch.jar

  3. I tried to create both folder (New->Folder) called help_folder and a Source Folder (New->Source Folder) called help_source_folder, and put inside them a file of example called Master.hs (I took it from the JavaHelp archive).

Then from inside my application I did the following:

try {
    ClassLoader loader = this.getClass().getClassLoader();
    URL url = HelpSet.findHelpSet(loader, "Master.hs");
    //alternatively : URL url = HelpSet.findHelpSet(loader, "help_folder/Master.hs");
    //alternatively: URL url = HelpSet.findHelpSet(loader, "help_source_folder/Master.hs");
    JHelp jhelp = new JHelp(new HelpSet(loader, url));
} catch (HelpSetException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

Now the problem is the following: HelpSet object cannot be created because a null URL is returned by findHelpSet() method.

I have no idea on how solve this. Can someone put me in the right direction?

2

There are 2 answers

0
obscuredlogic On BEST ANSWER

Make sure the folder you create is inside your project's source folder (defaults to 'src'). If it's not then it won't be included in the output folder (defaults to 'bin') when it builds the project.

2
Oleg Mikheev On

There are two reasons findHelpSet() method will return null:

  1. It couldn't find Master help set file in your classpath. It happened to me a lot when I was using IDEs because they compile all your classes into some working directory and often 'forget' to copy files there with 'unknown' extensions, and hs is an extension that is most probably unknown unless you add it to your IDE manually.

  2. It could find it but it could not read it. This could be because of some security issues. Also an empty file is considered a file that could not be read from, which is a bug IMO, so make sure your Master file has some data in it.