jfuse icon indicating copy to clipboard operation
jfuse copied to clipboard

Locating libfuse more reliably

Open brett-smith opened this issue 11 months ago • 3 comments

First off, thanks for the great library. I have already got a working file system based on it, and so far it's been flawless. I thoroughly approve of the no/low dependencies approach :)

However, like other FFM API libraries I have worked with, it seems a bit hit-or-miss as to whether FFM will actually find the library out of the box. So this will often mean adding a java.library.path .

In the case of jfuse on my chosen development environment (Linux Mint), and despite libfuse3 being installed from the standard repositories (to /lib/x86_64-linux-gnu), the library path needed is ..

-Djava.library.path=/lib/x86_64-linux-gnu:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib

Why Java+FFM cannot find these itself is beyond me. Lots of other applications seem to locate libraries just fine! In my experience the situation is worse on Mac OS, particular when trying to link to standard libraries such as libc in "frameworks".

When I hit this problem in another project, I realised I had never seen this problem before when using JNA. It tends to just work and always locates the wanted library. The JNA project have been doing this for years, so I basically used their expertise and extracted the bits from JNA that deal with locating and loading libraries and used that to load for FFM.

This worked well, even to the extent the library bundling works (just put pre-compiled shared libraries in the resource path). And after having needed this a few times, I created a little library for it, NIH. I am not suggesting you use this directly, but the answer is in there, and the license is compatible should you want to.

brett-smith avatar May 14 '25 17:05 brett-smith

Thanks for sharing this, locating the lib is indeed a big pain. We will take a closer look at NIH when we find time for sure! 🙌

overheadhunter avatar May 14 '25 20:05 overheadhunter

On opensuse, libfuse3 gets dropped in /usr/lib64, however it doesn't create a libfuse3.so link, so you just have the versions:

> ls /usr/lib64/*fuse3* -lah
.rwxr-xr-x root root 274 KB Sun Jul 20 12:49:22 2025  libfuse3.so.3.17.3
lrwxrwxrwx root root  18 B  Sun Jul 20 12:49:22 2025  libfuse3.so.4 ⇒ libfuse3.so.3.17.3

I had to manually add a link to libfuse3.so for fuse3 to find the library.

jrivard avatar Aug 08 '25 22:08 jrivard

You can always adjust the lib path to your target systems by using the FuseBuilder::setLibraryPath method.

For our own system integration, see for example https://github.com/cryptomator/fuse-nio-adapter/blob/532a19bc668087305f1fd303854d5620281d10ae/src/main/java/org/cryptomator/frontend/fuse/mount/LinuxFuseMountProvider.java#L42-L56

infeo avatar Sep 09 '25 10:09 infeo