Read Property File in JAVA JAR File:

Did you ever came in a situation, where you exported a java project as a jar file and you got a filenotfound exception ? If yes, then this is not a problem with your code but it is a mechanism in which the normal file reading operation do not work in the java. Alternatively, we should use the below snippet of reading the property file, when you generate a JAR File.


Properties props = new Properties();

URL url = ClassLoader.getSystemResource("property file path");





The code above will help you reading a property file in a JAR File.

Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on ; I would like to hear from you :)