Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Java libjli library for?

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:

  1. What is the JLI library for?
  2. Do I need it for C/Java JNI development in RedHat/CentOS-only environments (no OSX)?
like image 654
Neal Avatar asked Jun 29 '18 13:06

Neal


People also ask

What is Libjli so?

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.

Where is Libjli so located?

The library you need is part of the openjdk package, and is location in: /usr/lib/jvm/java-1.7.


1 Answers

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.

like image 167
St.Antario Avatar answered Oct 02 '22 23:10

St.Antario