2 Replies Latest reply: Feb 2, 2010 8:07 AM by 843810 RSS

    Format for Helpset file URL

      I'm running on windows Windows XP.

      I'm new to Javahelp and I downloaded a simple demo app (source at the end of this post).

      I set up an Eclipse project and got the sample to compile fine.

      I placed the help files in the parent of the folder where my compiled class resides. I started
      the app and the help viewer displayed just fine.

      I then moved the help files to another location, and changed the URL to point to the new location as follows:
      URL url = HelpSet.findHelpSet(cl, "file://D:/D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs");
      This time a null pointer exception occurred and my debugger showed the "url" variable to be null.
      I also tried the following with no success:
      URL url = HelpSet.findHelpSet(cl, "file://localhost/D|/D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs");
      URL url = HelpSet.findHelpSet(cl, "file:///D|/D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs");
      URL url = HelpSet.findHelpSet(cl, "file://localhost/D:/D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs");
      URL url = HelpSet.findHelpSet(cl, "file:///D:/D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs");
      What format should i use?


      Sample App:
      import javax.help.*;
      import java.net.URL;
      import javax.swing.*;
      public class JavaHelpTest {
         public static void main(String args[]) {
            JHelp helpViewer = null;
            try {
               // Get the classloader of this class.
                 ClassLoader cl = JavaHelpTest.class.getClassLoader();
               // Use the findHelpSet method of HelpSet to create a URL referencing the helpset file.
               // Note that in this example the location of the helpset is implied as being in the same
               // directory as the program by specifying "jhelpset.hs" without any directory prefix,
               // this should be adjusted to suit the implementation.
                 URL url = HelpSet.findHelpSet(cl, "jhelpset.hs");
               // Create a new JHelp object with a new HelpSet.
               helpViewer = new JHelp(new HelpSet(cl, url));
               // Set the initial entry point in the table of contents.
              } catch (Exception e) {
                 System.err.println("API Help Set not found");
            // Create a new frame.
            JFrame frame = new JFrame();
            // Set it's size.
            // Add the created helpViewer to it.
            // Set a default close operation.
            // Make the frame visible.
        • 1. Re: Format for Helpset file URL
          I guess your folder is actually named D_ProgramFiles, otherwise it should just be file://D:/ProgramFiles/JavaHelp/MyStuff/jhelpset.hs.
          Anyway the findHelpSet method will look for the helpset based on a name, not an URL, I guess it's just using the classLoader getResource method, why don't you just try D:/D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs or /D_ProgramFiles/JavaHelp/MyStuff/jhelpset.hs or whatever shorter name your classpath lets you?

          • 2. Re: Format for Helpset file URL

            Thanks for this help. My setup and probably my post are a little confusing. The helpset is on my D drive in this location:
            I changed the value of the second parameter to findHelpSet to:
            But this did not work.

            I placed the helpset files in the same directory as the compiled class and changed the parameter to:
            where helptest is the package name and the viewer loaded fine.

            However when it comes to a real application and help files, putting the help files in the same location as the compiled class files is probably not the best technique. I'll have other questions at that time I'm sure.

            It still would be good to know why the first path I indicated above did not work.