0

I have a class that reads a config file from the project root but it is not finding the file.

My read class is in com.br.xxx.util package

        String filename = "config.properties";
        input = getClass().getResourceAsStream(filename);

This code returns null even though "config.properties" is in my project root. What am I doing wrong?

If I use:

InputStream input = new FileInputStream("C:\\Users\\xxxx\\git\\projectfolder\\project\\config.properties");
configFile.load(input);

It works, but I don't want to use a system path.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
AgamenonD2
  • 83
  • 1
  • 11

1 Answers1

0

config.properties must be in your classpath. when you deploy your project on tomcat, by default WEB-IN/classes is in classpath. Simplest solution is to move config.properties to WEB-IN/classes.

Farvardin
  • 5,336
  • 5
  • 33
  • 54