Jump to content
  • Advertisement


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


[java] Resource organization

This topic is 5916 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!