Reading Properties file in Java

Based on your exception, the InputStream is null, this means the class loader is not finding your properties file. I’m guessing that myProp.properties is in the root of your project, if that’s the case, you need a preceding slash:

InputStream stream = loader.getResourceAsStream("/myProp.properties");

Leave a Comment