aspose file tools*
The moose likes Servlets and the fly likes Unable to access Property file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to access Property file" Watch "Unable to access Property file" New topic
Author

Unable to access Property file

V Patil
Ranch Hand

Joined: Oct 04, 2008
Posts: 36
I am trying to access property file using Resource Bundle.
But i am getting an error Can't find bundle for base name Resources/Properties, locale en_US
this error is when i kept the Resources folder parallel to WEBCONTENT and SRC folder.(in Resouces folder Properties.properties file is present).
when i keep the properties file inside SRC folder it is accessible using
ResourceBundle rb = ResourceBundle.getBundle("Resources/Properties",Locale.getDefault());
I am using Eclipse.

Please help.
Thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
Resources are loaded using a class loading mechanism, so they need to be in the classpath. Eclipse may add additional folders to the classpath that normally aren't part of it.


Ping & DNS - my free Android networking tools app
pats Patil
Greenhorn

Joined: Dec 06, 2009
Posts: 4
what is the solution for this problem?
when properties file is kept inside src folder it is accessible.
Please help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
"pats Patil", are you somehow related to "Vikas Patil"? If so, let us know which account you'd like to keep so that we can close the other.

when properties file is kept inside src folder it is accessible.

No. Resources are loaded from the classpath, and the source folder should not be part of it.
pats Patil
Greenhorn

Joined: Dec 06, 2009
Posts: 4
both accounts belong to me.
you can close the one named Vikas Patil.
So what is the solution for this?
when i am trying to access the Properties.properties file kept parallel to SRC and WEBCONTENT i am getting an error Can't find bundle for base name Resources/Properties, locale en_US ???
else where i can keep the property file and access it?
please help?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
where i can keep the property file and access it?

I've answered that twice already.
Om Tejas
Greenhorn

Joined: Dec 02, 2009
Posts: 27
If I am not wrong.. the locale should en-US, not en_US. I am not sure if this effecting your functionality.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
If I am not wrong.. the locale should en-US, not en_US.

Actually, you are wrong.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to access Property file