What would be the best place to save jar files of libraries I want to use in a project, that are not in any repositories, and how should I set permissions?

Should I put them in /usr/share/java, or is it better to store them somewhere in my home folder?

What would be the most usefull access rights? Does it make sense to follow the convention in /usr/share/java of making a symlink with the package name to the specific version of the jar, and follow the permissions as used there?


If all the users in your system don't need access the files, you can put them in your home folder or even better in bin folder (create one if not already done) under your home folder. That way you have a personal bin directory which can be accessed from terminal without specifying the file extension or the program to open the file.

For example,


would make the terminal to run my-app.any_possible_extension with proper program (Sun's Java or Openjdk in this case). If you create the bin folder, you need to log out and log back in order for the system to recognise the new bin folder. Also, files in the personal bin folder must have been set as executable, otherwise terminal will ignore the file.

| improve this answer | |
  • Just to add that the file my_app.extension needs probably to tell terminal what program to use, for example sh files have the #bin/bash line. I don't have experience in java programming, so I can't tell if java files needs such instructions for terminal. – papukaija Feb 16 '11 at 1:14

definately better to keep 'local' changes out of a distribution area. When you need to upgrade later, you changes won't be removed or the upgrade won't fail because of an errant file. You just need to change the CLASSPATH environment variable to include the jar files in your home directory.

Since you are specifying your home directory, I assume that this is a personal project, not one to be published somewhere. If it a project to be published, then there should be a directory, likely named 'lib', under the project's distribution; for example, /usr/local/xyzzy/lib/*.jar (for the project 'xyzzy').

| improve this answer | |
  • Shouldn't it be /usr/local/lib/xyzzy/*.jar ? – Andres Jun 8 '16 at 20:05
  • Actually, it should be /usr/local/share/xyzzy/*.jar because they're not architecture-dependent... well, unless you messed with OS specifics... – Andres Jun 8 '16 at 20:15

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.