2 Replies Latest reply on Dec 21, 2006 12:05 PM by siddharthags

    read in packaged properties file

    siddharthags

      looking at previous posts I see this has been posted without much help. so I am trying my luck here again.. I have an existing class that reads in a props file packaged as org/foo/syprops.properties as

      ClassLoader.getSystemResourceAsStream("org/foo/syprops.properties");

      as expected and stated in the JBoss admin guide this returns the inputstream as null even though this works on other server configurations such as websphere and SJS. I am open to trying to change this to something that can universally work for example have tried putting the jar containing the properties in the CLASSPATH etc. does not seem to help.

      Any pointers?

      TIA

        • 1. Re: read in packaged properties file
          peterj

          You stated "props file packaged as" which I assume means that your poroperties file in within a jar file. Assuming your jar file has the following contents:

          org/foo/bar/Some.class
          org/foo/Other.class
          org/foo/sysprops.properties

          then from any of the classes in this jar file, you can load the properties file by:

          Properties prop = new Properties();
          prop.load(this.getClass().getResourceAsStream("org.foo.sysprops"));

          • 2. Re: read in packaged properties file
            siddharthags

            thanks Peter that works with the addition that I have to give the absolute ath of the properties file beginning with a /.