• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

properties file in eclipse

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

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("xxx.properties"));

where should i place the java file .

can anyone please help as i am beginner

Thanks ,
vinay rajnish
 
vianyrajnish rajnish
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

getClass().getResourceAsStream("xxx.properties")

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


any suggestion

thanks ,
vinay rajnish
 
Saloon Keeper
Posts: 28765
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic