• 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

Java Property File

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I use a property file?
  • how do I write it?
  • where do I save it?
  • how do I use its properties inside a class?


  • I searched a bit in java.sun.com and the Java Tutorial but didn�t find anything on this topic.
    Thanks,
    Francisco
     
    Bartender
    Posts: 1844
    Eclipse IDE Ruby Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Properties are passe; Preferences are the current rage. That said, properties are still useful for quick-and-easy settings.
    Basically, a Properties file contains key/value associations:
    ConnectionURL=jdbc dbc:MyDatabase
    DriveClass=sun.jdbc.odbc.JdbcOdbcDriver
    Password=pass_word
    UserName=web_user
    This is an example of a properties file specifying a Database connection.
    It is saved in the classpath with a .properties extension. (Say, as "MyDatabase.properties" in the "mypackage" package.)
    You use it by using the java.util.(Property)ResourceBundle class

    Of course, you can do other things with it as well. See the java.util.PropertyResourceBundle documentation for more information.
     
    Francisco A Guimaraes
    Ranch Hand
    Posts: 182
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    What�s the difference between a property and a preference? why is the last one better? Can you give an example?
    Francisco
     
    Joel McNary
    Bartender
    Posts: 1844
    Eclipse IDE Ruby Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Unfortunately, I've not had the time to really get into the Preferences API, so my code still uses Properties. In the coming months I'll get around to making the switch (I've wrapped the Properties API anyway, so switching to Preferences should (hopefully) noe be that big a deal.)
    However, you can read Thomas Paul's newsletter article on the subject.
    [ May 27, 2003: Message edited by: Joel McNary ]
     
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,
    I am developing some java classes(APIs) which will be used by other developers in there applications.
    I use a property file to store application dependant values. ex:log file path name.
    I have put the .propertie file to same folder where my class file exists. In command prompt
    my class is running without problem. But when I use my IDE (Eclipse 2), it does not work(it cannot fine the file)).
    I have added the properties file to system classpath, it also not work.
    Please help me.
    Sudheera
    [ May 27, 2003: Message edited by: Sudheera Liyanage ]
     
    permaculture is largely about replacing oil with people. And one tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic