4 ms·
So, other people have already answered this, but this does seem to be a gap where many developers lack some piece of knowledge to chain the whole solution toget
by aardvark179 2y ago
So, other people have already answered this, but this does seem to be a gap where many developers lack some piece of knowledge to chain the whole solution together. You normally package this sort of thing by putting the native library in a jar, extracting it to a tmp file that will be deleted on exit, and opening that dynamic library.
I’ve met many perfectly reasonable developers who do know all those steps can be done but can’t put them all together - maybe because it just hasn’t clicked that you can store a library in a jar. It feels like something tutorials should cover, but I think falls into the, “surely everyone can work it out?” category.
- chii 2y ago> extracting it to a tmp file i wonder if there's a way to do this entirely in memory? Because some deployment scenarios might not have disk space at all.
- MobiusHorizons 2y ago/tmp is often a RAM disk in such cases
- xxs 2y agonot with java - it needs a path. Of course if you have a ram disk (e.g. /tmp) it'd do the job.
- rwmj 2y agoTechnically memfd_create will let you create a file descriptor backed by a memory region. However in Linux I don't believe there's a way to dlopen that. (Maybe dlopen /dev/fd/... might work?) In FreeBSD there's a fdlopen library function. Edit: glibc proposal which was never accepted: https://sourceware.org/bugzilla/show_bug.cgi?id=11767 https://sourceware.org/bugzilla/show_bug.cgi?id=11767
- sedro 2y agoYou would also need to learn about Maven profiles and activation. And for other build tools, you'll be delighted to know they have partial support.
- xxs 2y ago>exract it to a tmp file that will be deleted on exit, actually you delete it immediately (after load) on anything that's not windows... even then but it's likely to return false. deleteOnExit just stores the path to delete and uses a shutdownHook to actually call delete. Nothing really special about it