How write path to file properties?

Tags: ,

I wrote a program with two language. I created a file When I attempted to get properties from the file, I got the error:

Exception in thread “main” java.lang.NullPointerException at java.util.Properties$LineReader.readLine( at java.util.Properties.load0( at java.util.Properties.load( at at

I think it is because I have an incorrect path to properties. is located at The main class locate

My code:

public class Helper {

    private static String getProper(String lang, String value) {
        Properties prop = new Properties();
        InputStream inputStream = Helper.class.getClassLoader().getResourceAsStream("./src/main/");
        try {
        }catch (IOException e){
        String word = prop.getProperty(value);
        return word;
    public static void main(String[] args){


You are trying to load ./src/main/ path as a resource. This won’t work, resources are referenced not as file system files but as classpath paths. Usually it would be:

Properties prop = new Properties();
try (InputStream in =
          Helper.class.getResourceAsStream("/")) {

however in most build systems resources are placed under /src/main/resource while in your case the path is non-standard which can imply problems with packaging the JAR.

It also looks like you are dealing with localized resources due to locale suffix in the file name. Perhaps instead of java.util.Properties you should use java.util.ResourceBundle.

Source: stackoverflow