Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

classpath problem

Status
Not open for further replies.

samit700

Programmer
Sep 23, 2003
52
US
Hi,

I have an " application properties " that I use in my actions and classes. I place this file in WEB-INF/classes directory which is supposed to be in the classpath of the web application. But I am getting "File not found" exception when I try to read the file using:
File f = new File("portal.properties");

Any suggestions ?

thanks, Samit
 
You cannot just load a file in your class path like this. You use can either user absoulte path like:

File f = new File("c:/project/test/classes/mypackage/portal.properties");

or use relative path to your current directory.
File f = new File("../../classes/mypackage/portal.properties");

If this is a properties file, and the file is within you class path, you can then use java.util.ResourceBundle to load it using the classpath way. example:

ResourceBundle rb = ResourceBundle.getBundle("mypackage.portal");
String yourValue = rb.getString("your.value");

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top