Dynamically determine location for a file relatively to current CLASSPATH

Hi All,
I am quite new to Java and I have a problem.
I am trying to write a program that can dynamically determine the location of a file (the class that handles this will only have the relative path/file name).
Eg.
File f = new File(config/MyMainCfg.file);
The class will then need to be "smart" enough to locate the file "config/MyMainCfg.file" in relative to the current CLASSPATH.
Hence, if the current CLASSPATH is /usr/local/myclasspath, then the file should be able to be located at "/usr/local/myclasspath/config/MyMainCfg.file".
My main question is:
(1) If the CLASSPATH contains multiple values (i.e. CLASSPATH=path_1:path_2:path_3), how do I correctly determine the current CLASSPATH that the currently executing program is using?

I have a method that does something like that. A few lines of it below:
   // Get location class loaded from
   public final static String getHomeLoc(Object obj, String className) {
        URL ourLoc = obj.getClass().getResource(className);
       ... code gets ourLoc.toString()  and parses it.
// Called by:
     String loc = getHomeLoc(this, "MyClassname.class");

Similar Messages

Maybe you are looking for