This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: help.html in runme.jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: help.html in runme.jar" Watch "NX: help.html in runme.jar" New topic
Author

NX: help.html in runme.jar

Rob Pearson
Greenhorn

Joined: Jun 12, 2003
Posts: 19
Jumping to a completely different part of my assignment, I was just playing around with a help system built into the application. I've just constructed a JEditorPane and set its contents:

This works fine, and I've even got a little HyperlinkListener to follow links in the help file. Looks pretty cool.
However, I'm having problems packaging into my runme.jar file
I can change the url to "jar:file:build/runme.jar!/suncertify/Help.html"
and this also works, but this is a hardcoded path to the jar file . Does anyone know how I can get around this?
Cheers
Rob


Assignment: URLyBird 1.3.3, using Java 1.4.0_01<br />Status: Designing, Experimenting, Reading.
Vikalp Setya
Greenhorn

Joined: May 10, 2003
Posts: 18
Hi,
Why don't you go for Java Help system which provides you with a JDialog/JFrame with tabs for
viewing contents, viewing the index of the content and searching the content as well, just like any other windows application provides. You can print the help contents as well, all done by the help system itself. I used it in one of my projects.
Follow the link :
http://java.sun.com/products/javahelp/index.html
For your problem, have you tried
URL url = getClass.getResource("filename");
editorPane.setPage(url);
All the resources from the jar file can be extracted by using the getResource method on class object or the class loader object. See how to use this api. this is the solution but i haven't tried it yet.


Regards,<br />vikalps
Rob Pearson
Greenhorn

Joined: Jun 12, 2003
Posts: 19
Thanks Vikalp,


works fine. The Java Help stuff looks good, but maybe a bit big, and since I didn't write it, I don't fancy including it in my submission.
Cheers
Rob
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11464
    
  94

Hi Rob,
I don't know if we can use the Java Help System, as it may contradict the requirement that "you must not submit any code that is not your own work".
Personally I left the HTML files as standard files on the hard drive. That way my online help system could access them, or the user could use any web browser to access them.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Rob, double check your spec, and make sure it doesn't say your file must be called userguide.html OR .txt, and must be packaged at the same level as your runme.jar.
our spec may be different, so dont take my word for it, but double check, and accept my apology if I wasted your time.
Rob Pearson
Greenhorn

Joined: Jun 12, 2003
Posts: 19
My help doco should be html, text OR within the application as a help system.
Andrew, you said I left the HTML files as standard files on the hard drive. That way my online help system could access them, or the user could use any web browser to access them..
How did your online help system find the files if they weren't in the jar file?
Cheers
Rob
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11464
    
  94

Hi Rob,
How did your online help system find the files if they weren't in the jar file?

I determined a relative path from the directory where the user started, or from where the executable jar file was, or a few other tests....
My code did some checking for where files were at startup, and could handle a fair bit of files being moved and / or starting in different directories.
I documented how these tests worked, and under what conditions they could fail to find the help files, and how that situation could be handled. Went way outside spec, but had fun doing it
Regards, Andrew
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Rob Pearson:
My help doco should be html, text OR within the application as a help system.
Andrew, you said I left the HTML files as standard files on the hard drive. That way my online help system could access them, or the user could use any web browser to access them..
How did your online help system find the files if they weren't in the jar file?
Cheers
Rob


Hi Rob, heres what I meant
at the root, which includes runme.jar

A directory called docs, containing the following items at the top level:
...
which must be called userguide.txt, or multiple HTML files which must all be accessible from a starting point document that must be called userguide.html.

as for reading it when not included in your runme.jar , something like this will do.

replace literals with constants where needed
 
GeeCON Prague 2014
 
subject: NX: help.html in runme.jar