• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to read .properties file in Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am useing WASD 5.1.1 and I need to be able to read a .properties file in java. I'm new to java and have searched everywhere and can't seem to find out how to make this work.

I can read the file fine in a .jsp file, but I need to read it in some of my classes I have written. Can someone please point me to a tutorial or tell me how I can do this.

Thanks,

Greg
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
put the file in any folder and add the folder ws.ext.dirs so that this file would be in your classpath in your server and you can pick this file in your program

steps are as below
1. go to server perspective
2. double click on server
3. go to environment tab
4. add the folder in ws.ext.dirs

Shailesh
[ June 29, 2005: Message edited by: Shailesh Chandra ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just place the properties file in your application classpath, and do the following in your Java code:

Properties props = new Properties();
props.load(this.getClass().getResourceAsStream("/somefile.properties"));
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you can put it in your application's web.xml (as opposed to specifying it in your server configs, which may be shared by multiple applications). More in this thread.
 
reply
    Bookmark Topic Watch Topic
  • New Topic