The usual place to store my Java libraries and applications on UNIX-based systems

I usually store Java files and JAR files downloaded from the Internet to the ~ / Java folder on my computer (OS X machine). I have been doing this since I was a Windows user. However, I think that on UNIX-based systems, user local applications are usually stored in a different directory. I have the feeling that this directory should be /usr/local/ , /usr/local/USERNAME , /opt/local or /opt/local/USERNAME , but I'm not sure. Any ideas I can use for this purpose?

Please note that I am talking about archive files that I download from the Internet, unpack and use locally, and not programs that have installation scripts or MacPorts, etc.

+6
java linux unix macos
source share
5 answers

There is no blessed way to do this. However, you may come across several versions of the can, and then it just goes down.

I usually download the jars that I need as a distribution, and unpack them into my own folder, and then add the jars to the projects where I need them in my IDE. For libraries, the general approach is to use Maven and dependency handling.

So my suggestion is to keep your current way of doing it if you like it, but each project is in its own folder, for example

 ~/Java/jakarta-commons-net-1.1.8/commons-net.jar 
+2
source share

The couple answer is that you do not have to load banks manually, you should use Gradle , Ivy , Maven or something similar to manage your banks for you. These tools use a simple specification of your dependencies as input, as well as finding, loading, storing and providing all the necessary jar files. It takes a bit of getting used to, but pretty great when you are in full swing.

The direct answer, however, is that in orthodox unix these files belong to /usr/local/share . usr because they are read-only data that are not part of the underlying operating system, local because they are not provided by the operating system (which the rest of /usr belongs to) and share because jar files are architecture independent.

Note that in FreeBSD, the "ports" package management system places files in /usr/local , but I believe that it shares it with the local administrator. There is no other place where only local files go.

If the system has an agreement on where the packages managed by the package go, copy them under /usr/local . For example, on Ubuntu there is /usr/share/java , so you should use /usr/local/share/java .

Also, if the system has an agreement for version processing, copy this. Again, on Ubuntu, banks are all stored in the same directory with version numbers in the name, but with symbols without a link indicating the default / latest version. So, I have a file in /usr/share/java/xstream-1.3.1.jar and a symbolic link to /usr/share/java/xstream.jar pointing to it. I would use the same approach in /usr/local/share/java .

Now that for orthodox unix. You are on OS X, which is not orthodox unix. However, the principles apply: find how the system stores the banks it provides and transfer them to the user-managed file system space.

+13
source share

Apple has a note providing / Library / Java / Extensions as a directory for common banners and ~ / Library / Java / Extensions for jars just for itself. These paths are in the class path.

Banks can be anywhere while this catalog is on the way to your class. (I am using the version of Thorbjørn Ravn Andersen style I am using ~ / Library / Jar / jakarta-commons-net-1.1.8 / commons-net.jar)

See Tom Anderson's answer for a better way to do this with ivy, etc.

+3
source share

You might want to read the / opt or / usr / local file system hierarchy standard , probably, but you should read the FHS definitions first.

+2
source share

On FreeBSD systems, the location is ${LOCALBASE}/share/java - and its subdirectories. Not all software ports respected this, but they should.

LOCALBASE usually /usr/local - if not overwritten by the system administrator.

+1
source share

All Articles