The moose likes IDEs, Version Control and other tools and the fly likes properties file in eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "properties file in eclipse" Watch "properties file in eclipse" New topic

properties file in eclipse

vianyrajnish rajnish
Ranch Hand

Joined: Apr 22, 2007
Posts: 70

I am writing a java file in a package like to read the database
and created a properties file xxx which has user , password ..etc all db information and placing in the same package

but i am getting the file not found exception.. why? its not finding the properties file .

this is the java code i am writing in java file

Properties properties = new Properties();
properties.load(new FileInputStream(""));

where should i place the java file .

can anyone please help as i am beginner

Thanks ,
vinay rajnish
vianyrajnish rajnish
Ranch Hand

Joined: Apr 22, 2007
Posts: 70


i tried this too.. which returns inputstraem object ..but invain.

any suggestion

thanks ,
vinay rajnish
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

In your first example, the file will be searched for in the application thread's current working directory. Usually, it's better to supply an absolute filesystem path so there won't be any doubt.

In your second example, the resource needs to be in the classpath that the current class was loading from. This one can be a little tricky, I've found.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: properties file in eclipse
It's not a secret anymore!