Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By JosAH

Thread: Better way to load resources from resource-only package

  1. #1
    Stoyicker is offline Member
    Join Date
    Jan 2012
    Posts
    32
    Rep Power
    0

    Question Better way to load resources from resource-only package

    Hello,

    I've got a package, res, which is said to contain all the resources of my application. To easily load them, I have a class inside that package, with only this code:

    Java Code:
    package res;
    
    public abstract class ResLoader {
    
    }
    Then what I do to load resources from any other class is:

    Java Code:
    ResLoader.class.getResource(resourceName);
    Am I wrong or there is a better way to do this?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,999
    Blog Entries
    7
    Rep Power
    19

    Default Re: Better way to load resources from resource-only package

    You can also specify the absolute path for your resources: /res/YourResource and use any Class object you want.

    kind regards,

    Jos
    Stoyicker likes this.
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. could not load load from location:/test_subreport.jasper
    By jadeite100 in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 03-27-2012, 11:43 AM
  2. Compiler runtime package load error
    By Dark-Redd in forum Advanced Java
    Replies: 17
    Last Post: 10-09-2011, 09:21 AM
  3. Resources load in Eclipse but not in standalone .jar
    By leonsbuddydave in forum New To Java
    Replies: 0
    Last Post: 01-14-2011, 05:07 AM
  4. Replies: 1
    Last Post: 12-21-2010, 01:42 AM
  5. Replies: 0
    Last Post: 03-22-2010, 02:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •