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

Java property files best practices

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to read the property file. Could suggest me the best way to handle the property file.
My code is deployed on the server as a jar file.
I have to totally avoid the hardcoding.

Currently I am reading the properties using.

Properties prop = readProperties("C:\\PPMCustomCode\\DemandService.properties");
String endpoint = (String)prop.getProperty("ENDPOINT_URL");

It is not convincing & not a best way.
I tried using the resource bundle also still some hard coding remains. Can I keep my properties file in the same folder as the jar file & it will take the relative path? In RAD we could configure it in the admin console. I don’t have that liberty to use server configuration settings here, as I am working on JBoss.
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok here is how i am reading the property file in IBM websphere Appliation server

I have Set the System propery in the jvm command line option in websphere whose value is the path to property file

Then inside the code read the System property then use it read the property.

e.g.

system.properties
log_file_property_path=c:\app\log4j.properties
app_secific_property_path=c:\app\app.properties

then set the System property using -Dfile_paths="path to system.properties"

then in the code

String s=System.getProperty(file_paths);

Property p=new Property(s);

FYI

how to set system property in JBOSS visit here
JBOSS
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Parag Sk", please check your private messages for an important administrative matter.
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic