Accessing .properties files within a Livecycle ES/ADEP DSC

by kai on 12/08/2012



The other day Darren asked about how to access a properties file with some settings from within a Livecycle ES resp. ADEP DSC on the livecycle developers mailing list. I responded there, but I thought it’d be useful to post the solution here as well.

Essentially a Livecycle/ADEP DSC is nothing else but a .jar file that’s been crafted in a certain way. Darren wanted to have the .properties file within the DSC and needed to know how to access the file from Java code within the DSC. Here’s a working approach how this can be done:


InputStream is = this.getClass().getClassLoader().
 getResourceAsStream("your_properties_file_here");

Properties prop = new Properties();

if (is!=null) {
 try {
  prop.load(is);
  return prop.getProperty("someProperty");
 }
 catch ( ...probably IOException of some kind... ) {
  ...
 }
}

To refer to the actual file, starting from the jar’s root will work:


getResourceAsStream("folder_with_the_propertyfile/
 agentk.properties");

There you go, have fun writing DSCs with .properties files!

Comments on this entry are closed.

Previous post:

Next post: