Load Properties File Classpath Java
If you want to read Properties file values using classpath then its mandatory to put property file in classpath otherwise you will get exception. If you keep your property file inside src folder then it will be available to the classpath. If your existing project structure have property file outside src folder then you will have to set path of the file in classpath.
- Sample Java project structure from where we will read JavaHonk.properties file and print all its key values.
If your properties file is in maven project structure below:
- Then you could read as below by LoadPropertiesAndReadValue.java:
- For details please read oracle documentation here