• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • 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
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!