I coded a Java application (in this case an Apache Camel application) that I package as a jar file. It's an executable program (not a library). I am wondering where is the appropriate place for such jar application on my production Unix system, /usr/local/name-of-the-app/, /usr/local/bin/name-of-the-app/, /opt/name-of-the-app/?
Also this application relies on some property/configuration file (containing for instance database credentials, API keys, etc.), should this file be in /etc/name-of-the-app/config.properties?


Since it sounds like you are not distributing this through a package manager, the convention I have heard of is to put it in a folder called /opt/name-of-app and put the config files in that directory as well. If you package it as a zip file, this allows your users to install it quickly and conveniently by unzipping the file to /opt/.

Tangentially related, but if you're deploying .jar files to Linux machines, you can make them 'properly' executable very easily, which makes life easier for your users: http://skife.org/java/unix/2011/06/20/really_executable_jars.html

| improve this answer | |
  • Indeed no package manager. This is a non public "administration" tool that is very specific to our business and will be installed only on one of our own servers. – Maxime Laval Dec 8 '16 at 15:44
  • 1
    In that case, /opt/ is almost certainly the right choice. This ensures that the package manager will not do anything to harm it, and putting everything including configs in /opt/app-name means that installing a new version or backing up an install is easy and convenient. – Groomblecom Dec 8 '16 at 21:56
  • Ok, thanks. Just wondering (as a non expert ;-)) what would be the bad side of having the config file(s) in /etc/name-of-the-app/? – Maxime Laval Dec 8 '16 at 22:12
  • Well, the first issue is that on most distros, /etc/ is (by convention) managed by a package manager, so you are mixing automatically and manually installed config files. Second, for an app like this, you can just zip the entire /opt/app-name directory, copy, and unzip on a new server, and get your config files copied over at the same time. Third, for whoever has to maintain this, finding the config is easy because they will probably check in the install location first or second. – Groomblecom Dec 8 '16 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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