Re: positioning files for use from both IDEs and JARs

"Richard O. Hammer" <[email protected]>
Newsgroups gmane.org.user-groups.trijug.juglist
Message-ID <[email protected]>
I believe our application does what you want.  Here is the code involved:

public class Utility {
   ...
   private static Properties labProperties;

   public static Properties getLabProperties(){
     if(labProperties == null) {
          labProperties = new Properties();
         try {
            InputStream is = new FileInputStream("lab.properties");
           labProperties.load(is);
           is.close();
         } catch (Exception ex) {return labProperties;}
     }
     return labProperties;
   }
   ...
}

In Eclipse we keep the lab.properties file in the project's root 
directory (where also live src/, bin/, .classpath, and .project).  When 
we make a jar of the stuff in bin/, then we deploy that jar and the 
lab.properties file into the same directory, and the application finds 
it in both cases

  ... unless I am missing something.  I can confirm this on Monday 
morning if this doesn't work for you.

Rich Hammer


Thomas L Roche wrote:
> I'm wondering how to position a file (either a .properties or a
> preferences XML) in filespace so as to satisfy all the following
> requirements: it can be
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.