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");
if(url!=null)
props.load(url.openStream());
___________________________
The code above will help you reading a property file in a JAR File.