• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: help.html in runme.jar

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rob Pearson
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic