This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Cannot Find Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cannot Find "Properties" File" Watch "Cannot Find "Properties" File" New topic
Author

Cannot Find "Properties" File

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I have a MessageResources.properties file that contains the text to be displayed on the labels and buttons in the form.
Nonetheless, I got HTTP Status 500 and the problem is that the text provided in that file cannot be picked up - I think it results from not finding the file.
I checked:
1. name of the file: it is a correct spelling
2. location of the file: it is in the correct directory
3. type of the file: the Windows Explorer shows the type of that file is a PROPERTIES file
I need your experience to tell what else could go wrong. Please help.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Jen,
Are you trying to load the properties file thru a servlet? If so the problem could be that the servlet can't see a file on the host's file system. All it is going to be able to see are files in its virtual path.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
The properties file is kept in the same directory with all compiled servlet class files.
I am very frustrated by the problem.
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
[mods: plz move this thread to Servlets forum]
I was totally frustrated with this for a while. I got intermittent behavior and figured out that when I start Tomcat from the directory containing .properties file, it worked. I think it has to do with the classloader finding it in that case.
Fortunately, there's a much better solution than that.
You must use Class.getResourceAsStream() so that tomcat can find the file.
Here's an example:


comp.lang.javascript FAQ: http://jibbering.com/faq/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot Find "Properties" File
 
Similar Threads
Quesiton regarding Java Property
Default access variables
Question about properties file
Log4J Configuration
Replace words in a file by reading a properties file