How To Read Properties File In Java

A Beginner’s Guide With an example Project

Bhargav Bachina
Bachina Labs

--

Photo by Michael Jasmund on Unsplash

Most of the time you need to read configurations properties from the files, for example, you don’t want to put database names, passwords in the code directly. Not only database properties, but there are also so many reasons such as reading properties according to the language, etc. In this post, we will see how we can read the properties file in Java.

  • Prerequisites
  • Example Project
  • Implementation
  • Summary
  • Conclusion

Prerequisites

There are some prerequisites for this project such as Apache Maven, Java SDK, and some IDE. You need to install all these on your machine if you want to run this example project on your machine.

Once you install all of the above you can check the version of both maven and java with the following command

java --version
mvn --version

Let’s generate the basic Maven project with the following command.

mvn archetype:generate -DgroupId=com.bachinalabs.fileread \…

--

--