Results 1 to 4 of 4
  1. #1
    nn12 is offline Member
    Join Date
    Sep 2008
    Rep Power

    Default Reading properties file

    In my java app there is a code which reads the properties file from src/main/resources folder.

    Java Code:
    public class MailerProperties {
    	private static Properties properties;
    	public MailerProperties() {
    		properties = new Properties();
    		InputStream inStream;
    		try {
    			inStream = (new ClassPathResource("")).getInputStream();			
    		} catch (IOException e) {			
    	public String getValue(String key) {
    		return properties.getProperty(key);
    Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.

    Question: Currently it uses ClassPathResource("") to read the prop file. What change I need to make to read it from outside the jar file

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Rep Power

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    Except they don't want to read it from the jar.
    They want to supply it with the jar and read it from that directory.

  4. #4
    nabhanya is offline Member
    Join Date
    Sep 2014
    Rep Power

    Default Re: Reading properties file

    '.properties' files are mainly used to maintain project configuration data, database config or project settings etc. Each parameter in properties file are stored as a pair of strings, in key and value format, where each key is on one line. You can easily read properties from some file using object of type Properties.

    Please visit the below link for more details...

    [removed spammy link]
    Last edited by DarrylBurke; 09-13-2014 at 01:53 PM.

Similar Threads

  1. Reading a properties file
    By peiceonly in forum New To Java
    Replies: 7
    Last Post: 05-06-2010, 05:17 PM
  2. Unable to access file from jar file
    By mjwoodford in forum New To Java
    Replies: 0
    Last Post: 10-09-2009, 01:46 PM
  3. Weird path problem when reading properties file
    By jerry_popperq in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 03:32 PM
  4. Reading a properties file using resource bundle.
    By rudrakanth in forum New To Java
    Replies: 1
    Last Post: 02-27-2009, 12:23 PM
  5. Replies: 0
    Last Post: 01-30-2008, 09:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts