Archived

This topic is now archived and is closed to further replies.

pirate_dau

[java] Resource organization

Recommended Posts

As my project has grown, and I've added several little GIF files, and ini files, and things of that nature, I've found myself coming up against a problem. What's the best way to organize resources in a big java project? Should I have them inside the jarfile? Should I have an 'images' directory outside the jarfile to keep track of them? Should I have an 'images' directory inside the jarfile? I'm sorta leaning towards taking them all out of the jarfile (because right now they're in there, but just in a jumble in lots of different directories). But I've also been having the problem of being able to grab resources that aren't in the same directory as the source file. If it's in the same directory as the source file, then it's as easy as doing a this.class.getResource("icannotbelieveitsnotbutter.gif") -- but I've found that if it's in a directory above the source file, then it becomes far more difficult. A simple this.class.getResource("../icannotbelieveitsnotbutter.gif") doesn't seem to work. If it's in the directory outside the jarfile, a this.class.getResource("/images/icannotbelieveitsnotbutter.gif") doesn't seem to work either. Any advice on this? EDIT: Also, I think it's important to note that this is not JUST for images, but also certain datafiles in my project. I'm curious, though, as to whether or not I should prefer creating an Image using the this.class.getResource() method, or whether the Toolkit.getDefaultToolkit().getImage() method is prefered. -pirate_dau [edited by - pirate_dau on July 15, 2002 1:45:25 PM]

Share this post


Link to post
Share on other sites