Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best practice for the location of Java application configuration files?

Is there a best practice for where configuration files should be stored in a Java project. The file type is a Java properties file in this case, but I do use other file types in other projects.

Would the recommendation vary from stand alone application(.jar) to web app(.war)?

like image 809
James McMahon Avatar asked Jun 04 '09 16:06

James McMahon


People also ask

Where are configuration files stored in your application?

The machine configuration file, Machine. config, contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory.

Where are configuration files usually located?

All configuration files are in /etc , all binary files are in /bin or /usr/bin or /usr/local/bin . Here is the entire directory structure along with what they contain: / - Root directory that forms the base of the file system.

What directory stores configuration files specific to a system?

The /etc hierarchy contains configuration files. A "configuration file" is a local file used to control the operation of a program; it must be static and cannot be an executable binary.


1 Answers

You'll find that many open-source projects follow the directory structure used by Maven. In this setup your application source code is kept in src/main/java, application resources, including properties files, in src/main/resources, and other config files in src/main/config. Files related to unit tests use a similar directory structure; src/test/java and src/test/resources.

Personally I tend to use this layout because of its widespread use. I also keep an "etc" directory beneath the project root to house files that aren't directly related to the application. For example, I keep configuration files for PMD and Checkstyle in etc.

like image 65
Erik Pilz Avatar answered Oct 23 '22 03:10

Erik Pilz