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 IDEs, Version Control and other tools and the fly likes Reading a properties file 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 » Engineering » IDEs, Version Control and other tools
Bookmark "Reading a properties file " Watch "Reading a properties file " New topic
Author

Reading a properties file

Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
Hi All,

I have created a properties file under the root of my project. I would like to read the file to retrieve some config values. Could some one point out the path to determine the file.

I am able to read the file when I place the file under WEB-INF/classes/test.properties with the below code.



Thanks in advance for your help. It is a JSP / Struts application.

Ananth Ram
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ananth Ram wrote:I am able to read the file when I place the file under WEB-INF/classes/test.properties with the below code.




Good. And that's exactly what you should be doing. So it works? Then what is your question? You mentioned a "project", which isn't a technical term in either JSP or Struts as far as I know.
Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
I meant the web project.

Root--> test.properties, file included.
Root --> src is the folder where my struts action package and other java code resides.
Root --> web is the folder where the jsp, css/images,etc resides.

I want to place the file under the root folder and read the same. Please let me know if I am not clear.

Thanks,
Ananth Ram


Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
Thanks,

I will have the properties file copied to the WEB-INF/classes folder using ANT script like other cfg files.

Ananth Ram
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I see. So this "project" is in some kind of IDE then? In that case this is a question about that IDE... whatever it is. Is there a reason you aren't telling us that? At any rate let me move this post to the IDEs forum.

By the way I have found that artifacts under the "src" folder get compiled into artifacts under the WEB-INF/classes folder in my IDE environment. Yours might work the same way.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading a properties file
 
Similar Threads
How to read properties file?
How to set the location of the property file in the class path
loading a properties file
error in opening zip file
location of a property file