• 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

How to make ResourceBundle to read property file from other location instead of bin?

 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a property file which is in bin folder, where class files are generated.I copied the demo.properties file in the bin folder and it seems to be working fine.But when I move the properties file to a src folder where java file is there. Its throwing an exception and unable to read the property file.

In my java code i have written



How can i change the path? should it be something like the below



Even doing the second code throws me an exception
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The getBundle() method of the ResourceBundle class searches your classpath for the resource named in that parameter. You can't put a file path in there. Basically you should put your demo.properties in your classpath somewhere; the API documentation (for getBundle()) is more precise but it's extremely comprehensive. Have a look at it anyway.
 
Vishal Hegde
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:The getBundle() method of the ResourceBundle class searches your classpath for the resource named in that parameter. You can't put a file path in there. Basically you should put your demo.properties in your classpath somewhere; the API documentation (for getBundle()) is more precise but it's extremely comprehensive. Have a look at it anyway.



But suppose if i Use SpringSuite and go to clean the project it will clean the class file along with the properties file, thats w hy wanted to knw how to change the location of .properties file.
 
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic