Robustly linking to

How to link to in a way that survives package updates?

There is a problem where some programs (the R library rJava in this case), cannot find due to some directory rearrangements. One proposed solution is to add its directory to ldconfig via a file in /etc/

See the StackOverflow solution for details:

The problem is that on Fedora, the path is: /usr/lib/jvm/java-1.8.0-openjdk-

Wouldn’t this path change when the openjdk package is updated? How can this be solved in a robust way that survives updates?