What is best practice to call `SymbolLookup.libraryLookup()` in cross-platform way?

Lev Serebryakov lev at blacklion.dev
Thu Jan 29 15:13:29 UTC 2026


Hello!

  I wonder, is there best practices for `SymbolLookup.libraryLookup()`? 

  I mean, in POSIX-like systems it look in system directories and I can simply pass `"libname"` as argument. But on Windows it doesn't work even with `-Djava.library.path` which points do directory with `libname.dll`, looks like I need ".dll" to name.

  Check for OS via property "os.name" looks like bad solution: maybe, on other systems, which I'm not ware about, I need add other extension, and my code which check will fails!

  And I cannot understand what should I pass in MacOS. I've tried "name", "libname", "libname.dylib" — nothing works. Library file is "libname.dylib" in directory passed as `-Djava.library.path". 

  Is here better and future-proof way?

  I can copy code from JNA, but I don't like it very much, to be honest.

Thnak you.

-- 
// Lev Serebryakov


More information about the panama-dev mailing list