Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm creating a project that I want to be able to distribute across platforms. I'm writing in Java and AWT which already gives me a pretty large range of devices, but I'm mostly interested in Windows and Linux (Debian/Ubuntu).

I'm trying to determine where I should put config files. I have application-wide configuration files and user-specific files. Where are common directories to put these files?

Here's my current setup:

Windows:

App Config: %PROGRAMDATA%\MyApp\config\

User Config: %USERPROFILE%\AppData\Local\MyApp\

Other:

App Config: /opt/MyApp/config

User Config: $HOME/.MyApp/

share|improve this question
4  
Sounds good to me. –  Robert Harvey Aug 8 '12 at 23:18
2  
If you're going to use environment variables to construct paths, at least use %LOCALAPPDATA%. There's nothing that guarantees that the path you constructed there from the user profile actually points out the local appdata. If you've got Win32 bindings, prefer Known Folders. –  Lars Viklund Aug 9 '12 at 1:51
add comment

2 Answers

up vote 3 down vote accepted

This sounds OK, it's pretty much what most software does. But in Linux, you might want to put the app configuration files in /etc (or under a subdirectory, e.g. /etc/myapp) as it's more fitting to the FHS:

/etc Host-specific system-wide configuration files

Also, you might want to put user configuration in ~/.config/MyApp rather than ~/.MyApp. This helps reduce clutter in the user's home directory.

share|improve this answer
add comment

I'm no expert, but in my experience, Linux puts some default (non-editable) config files in /etc/your-app-here, whereas user-editable config files these days go in ~/.config/your-app-here, i.e. $HOME/.config/your-app-here. Also, http://www.freedesktop.org/wiki/Specifications/config-spec

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.