loading properties file in plugin with STATIC init

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

loading properties file in plugin with STATIC init

nicola76b@libero.it
Hi all,
times ago i wrote a plugin that use a properties file to configure it.
To load this properties, code was something like this:

---
Properties stageProp = new Properties();
InputStream resource = getClass().getClassLoader().getResourceAsStream("initLStepStage.properties");

if (resource==null){
  //error("cannot find init stage \n properties file!!");
  return false;
}

try {
  stageProp.load(resource);
  String par1 = stageProp.getProperty("parameter1");          
}
---

I PUT THIS PLUGIN (AND PROPERTIES FILE) IN A SUBFOLDER "LStep" OF IMAGEJHOME\PLUGIN and plugin work!!

now i want to improve this plugin with new features in imagej and i NEED a STATIC INITIALIZER.
Since in static init does not exist "this" o "get class", I try to load my properties with
something like this (folder is the same):


---
static {
  Properties stageProp = new Properties();      
  InputStream resource = ClassLoader.getSystemClassLoader().getSystemResourceAsStream("initLStepStage.properties");
}
---

but resource is always NULL...

Can someone help me?!?!

Thanks,
   Nicola