This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class.getResource Problem

 
Dipse smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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?
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic