2

I'm making a Swing application that will only run on Windows and I want to package everything into a single .jar file. I want to include a .chm help file in the JAR and be able to launch it from clicking a JMenuItem marked "Help" or "Contents" (I already have a working understanding of creating AbstractAction subclasses). How can I programmatically open a .chm file from a JAR file?

2

1 Answer 1

4

Desktop provides an open() method. You'll probably have to retrieve the .chm as an and park it at a known location in the file system.

6
  • 1
    Maybe if the OP distributes the JAR as a zip file, the jar and chm can be in the same directory and thus eliminating the need for embedded resource ? :)
    – An SO User
    Sep 2, 2013 at 18:16
  • @Little Child, I was considering that, but there is the possibility that somebody will end up just taking the JAR with them and then missing the CHM. I suppose a slightly lazy workaround would be to copy the CHM to some place on disk if it can't be found at runtime, but I still want a one-file solution if possible.
    – SimonT
    Sep 2, 2013 at 18:19
  • @LittleChild": Good idea. My only reservation would be mission creep on the Windows only requirement. I'd at least leave hooks for a strategy pattern.
    – trashgod
    Sep 2, 2013 at 18:21
  • @trashgod You mean create a cross-platform help file ? :)
    – An SO User
    Sep 2, 2013 at 18:22
  • 1
    There are cross-platform viewers for CHM like these: en.wikipedia.org/wiki/….
    – SimonT
    Sep 2, 2013 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.