• 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

class.getResource Problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My program has a very simple help system that uses HTML files. These files are loaded as follows:

This worked fine when developing the program. The html pages loaded and were displayed in a JEditorPane, but when i put the classes and the other files needed (including the help files) into a jar file the html files cannot be found and i get a invalid url error. What am i doing wrong?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inside the JAR file, in the same folder as the HelpDialog.class file, is the help folder there as well?

Another thing, with resources you can just use / on all platforms. No need for the use of File.separator there.
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you change your resource path to "/help..."?
 
Dipse smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried all your suggestions and have also tried a few other things in the last few days and have been unable to get it to work. The program is a petrol pump simulator and is a project for school. The help files are located in the jar file in a folder called help. The problem i believe is to do with the fact i am accessing them as a URL because i also have a txt file in the jar file in a folder called data which the program can read and write from perfectly well. So at the moment i am stumped. Any suggestions are welcome, i am willing to look at other method other than using URL url = HelpDialog.class.getResource("help"+File.separator+children[i].getName());
TO get the HTML files so they can be displayed in the JEditorDialog.
Thanks so far for the help and for any future help.
 
Dipse smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still have not found a solution to the problem does anyone know of another way to display HTML documents in java?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic