Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:47:50+00:00 2026-06-01T05:47:50+00:00

I read all the questions with answers but still it doesn’t work for me.

  • 0

I read all the questions with answers but still it doesn’t work for me.

In my web application I have a jar which contains few images and xmls. These are required by the classes in that jar itself. So I modified the required lines as below:

I changed the classes inside my jar to refer the resources(which are present inside the jar itself) by using :

Thread.currentThread().getContextClassLoader().getResource(path) // returns null

I had also tried before :

MyClassName.class.getResource(path) // null again

I read a lot about this and got to know that the later line of code will be able to pick up the resources, but unfortunately neither of it works for me…am I missing something?

Note: Running on Tomcat7 and since I am running on Vista, I get the ‘path’ value as ‘\myFolder\images\’

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:47:51+00:00Added an answer on June 1, 2026 at 5:47 am

    There are few points one must take care when loading resources from within a jar, which is embedded in a web application

    1. Loading a file is different than loading a resource. When we use File.seperator it is usually w.r.t Files and absolute paths. It is not recommended for loading resources.
    2. When loading resources from within a jar, make sure you are not using the File.seperator and using the normal ‘/’ as it is relative path w.r.t the jar.
    3. If you are reading properties from an xml within the jar…and that property refers to another location, make sure you are reading it with the ‘/’ slashes. Again, File.seperator will not work for loading resources because it will replace ‘/’ with ‘\’ (windows system)
    4. Finally, when loading resources in your jar code, use the following lines

      MyCurrentClass.class.getResource(path)

    Hope it helps people dealing with xmls within jars in a web application

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read many answers to similar questions, but still didn't get to the answer
I've read all the answers on to this questions and none of the solutions
I read all the similar questions but mine is slightly different. The first time
Questions exactly like this have been asked before, i've read them all and tried
I know, there are tens of similar questions. I read them all and still
I read a few websites and questions but all were far beyond my level
First of all let me tell you that i have read the following questions
I've read some questions on SO about denying cross domain requests but all just
I've read a few other questions that seem similar but I'm still very confused,
I went through a bunch of already asked/answered questions, but it still wont work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.