0

I have two Java Projects, and I am trying to read the properties file in one from another. I have added "Infrastructure" Project in Build path of "Java" Project, and the properties file is at root folder, but I am getting java.io.FileNotFoundException I tried bunch ways, but couldn't make it work. Which part is causing the problem?

public static void main(String[] args) throws Exception {
    Properties properties = new Properties();
    properties.load(new FileInputStream("application.properties"));
}

Here is the Project Explorer;

enter image description here

1
  • Add a resources/ folder under src/ and load the properties file from the ClassLoader using getResourceAsStream(). See: SO: Loading files with ClassLoader Commented May 2, 2014 at 21:32

1 Answer 1

2

Use: properties.load(YourClass.class.getResourceAsStream("/application.properties")) instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.