Where to place a .jar file on Linux?

nowox :

I have got a custom built library for a Python service running with systemd (so available to all users and starting at boot time). This service uses my custom built .jar file.

Where should I copy this library?

I think that /usr/share/java/ is the right folder. Is this correct?

Victor :

If you are trying to follow good practices and this jar file is not shipped with your application, than you are correct, in accordance with the Filesystem Hierarchy Standard. There are secondary questions though.

1) Is your service installed via a standard packing system for your distribution ?

2) Is this jar file a component of your service, and is it only for your service ?

This will guide you to say things like: it is shared so it should go here. If your service is not using the standard packing systems, it is common practice to use a subtree of the /opt directory, including /opt/your_app/lib, but this would only helpful if your app is following that structure too, otherwise is just pollution.

IF you are using the packing system, then a good choice is indeed /usr/share/java/ or /usr/lib (if your app is called from /usr/bin or /usr/sbin). Another good choice would be inside /usr/local, only if this app of yours is host specific.

To make matters simple, if you are manually installing your app, not using something like .deb, use your app structure inside /opt, otherwise you will need to evaluate how this library is characterized, shared or not, specific to your host or not.

/usr/share/java/ is a common place of choice for java apps, but it is sometimes misused.

in any case, there should not be arguments to use subtrees out of /opt or /usr

with all that, I am almost sure, you are looking for /opt/your_app/lib, guessing you are packing your app and installing it yourself, also guessing this jar is only useful to your app.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=129706&siteId=1