• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading property file in a jar file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jar file going to be deployed in the web application web-inf\lib directory. However, one of the method that reading configuration value from a property file distributed together in the jar file fail to read the property file. It was pointing to the windows\system32 direcotry if i access it via jsp but it works fine if i run it standard-alone. Any way to work around this as this jar file should be self-provide classes, no configuration value should be passed in as argument.
I am using tomcat 4.1.2. Will it have the same problem if i deploy in other web container such as Webshpere? Any way to make it works across different web containers? Thanks in advance for any reply.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's probably because you are trying to load the properties file from the file system?

Re-write that code to use a classloader.getResourceAsStream() method.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Curwen wrote:That's probably because you are trying to load the properties file from the file system?

Re-write that code to use a classloader.getResourceAsStream() method.



Thanks Mike. I got around this problem and your solution helped me.

Shravan Kumar.M
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic