File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes where to place .properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "where to place .properties file" Watch "where to place .properties file" New topic
Author

where to place .properties file

zelynn goay
Ranch Hand

Joined: Jan 09, 2005
Posts: 30
Hi. i have one java file that uses .properties file. but it couldn't find the .properties file.
my dir is like this: tomcat/webapps/myapp/WEB-INF/classes/com/example/web/a.class

a.class
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

How are you trying to access the properties file?
zelynn goay
Ranch Hand

Joined: Jan 09, 2005
Posts: 30
Hi.

in my a.class, i have


i place a.properties file at tomcat/webapps/myapp/WEB-INF/classes/com/example/web, but it gives java.
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
Try using


Cheers!<br /><b>Annie</b>
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

When you try to load files the way you do, it tries to load the file from the 'current directory'. The problem here is that the current directory keeps moving depending on how you start your application, and it's not very useful in a web application anyway.

In web based applications you should keep your properties file inside the application and there are two common ways to do this. You'll find a useful discussion here.

Dave
zelynn goay
Ranch Hand

Joined: Jan 09, 2005
Posts: 30
Hi. Thanks for the guidelines. Managed to access the .properties file already.
 
wood burning stoves
 
subject: where to place .properties file