I am using JNI to allow C code to offload some work best done in Java. In this question I was trying to link the libjvm and libjli libraries for my code to work, but now I'm questioning whether I even need the JLI library.
I cannot find any documentation that clearly states what the purpose of the JLI library is.
This other SO question hints at JLI being some OSX passthrough library:
#elif defined(__APPLE__)
// jli needs to be loaded on OSX because otherwise the OS tries to run the system Java
As does this blog:
When compiling on OS X it’s very important to link the jli library before the jvm library
My questions:
The libjli.so is dynamically linked to the Java binary. It is one of the first libraries that the Java launcher tries to load. The Java launcher is required to be able to read all of Java's associated libraries in order to start properly.
The library you need is part of the openjdk package, and is location in: /usr/lib/jvm/java-1.7.
What is the JLI library for?
The libjli.so
contains a launcher interface for preparing arguments passed in the command line and launching the virtual machine with them.
The launcher main.c is the main entry point in all Java programs. It prepares the C command line arguments and passes them into JLI_Launch
function which performs argument parsing, loading virtual machine from libjvm.so
, forking primordial thread and then passing control to the JVM.
Do I need it for C/Java JNI development in RedHat/CentOS-only environments (no OSX)?
Very unlikely. If you need you are probably doing something wrong. At least I cannot imagine any useful general use-case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With