1

I've decided I want to create my own SQLite library for Java. SQLite is a C code base. I want to run this library on as many platforms as possible. Several potential users of my code base have HP-UX, AIX, and other uncommon architectures.

I have been using xerial/sqlite-jdbc for a long time and saw how it is building its JAR. It spins up several docker containers for each architecture, compiles SQLite and writes the compiled library files back to the resources/ directory.

It detects whatever architecture the JAR is running on, loading up the correct shared library. I am not clear on this step, so some guidance on how to reliably detect the architecture and make sure JNI finds the correct .so/.dll would be helpful.

Is creating docker images and Makefiles the recommended practice? Does someone have a starting point for various architectures, where I can just customize the Makefile/source folder? It feels like every time a new architecture comes out (like M1 recently) it means a lot of work for a lot of projects of this nature.

Mostly, I'm just confirming there's not something already out that other Java libraries are already using, before I invest a lot of time in this. Any additional guidance would be appreciated. Hopefully this question is specific enough.

Travis Parks
  • 8,435
  • 12
  • 52
  • 85
  • You can't run Docker on non-Linux Unices so it's not going to be so helpful for the situation you're describing. – David Maze Jun 26 '21 at 11:25
  • 1
    @DavidMaze I think the Docker implementation mentioned is just an example. It's not hard to do at all: just put multiple shared libraries into your jar file for whatever architecture you want to support. Then when you're running, figure out which one you need to extract. See https://stackoverflow.com/questions/26652014/load-so-file-from-a-jar for starters. Beware, though. There are lots if pitfalls and corner-cases, like `/tmp` being mounted `noexec` on Linux. I've also experienced classloader issues in complex applications. – Andrew Henle Jun 26 '21 at 11:47

0 Answers0