What is best practice to call `SymbolLookup.libraryLookup()` in cross-platform way?
Duncan Gittins
duncan.gittins at gmail.com
Fri Jan 30 09:50:41 UTC 2026
On Windows libraryLookup call does not require ".dll", for example this
works in jshell:
SymbolLookup ole = SymbolLookup.libraryLookup("ole32", Arena.global());
Kind regards
Duncan
On Thu, 29 Jan 2026 at 15:14, Lev Serebryakov <lev at blacklion.dev> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20260130/7e1b1655/attachment-0001.htm>
More information about the panama-dev
mailing list