Elektra
0.9.3
|
Allows you to write plugins in Java.
This plugin needs the JNA bindings to work. Furthermore, it requires Java 8 or later.
While the plugin internally uses JNI (thus the name), the Java binding for your Java plugin may use something different, e.g. JNA. The requirements for the Java bindings are:
elektra/Key
and elektra/KeySet
withThe Java plugin itself needs to have the following methods:
elektra/KeySet
(the plugin's conf) and elektra/Key
elektra/Key
elektra/KeySet
and elektra/Key
elektra/KeySet
and elektra/Key
elektra/KeySet
and elektra/Key
openjdk-8 and 9 do not work reliable: jvm crashes without usable backtrace.
When using non-standard paths, you have to set JAVA_HOME before invoking cmake. (For example when you unpack Oracle Java to /usr/local
or /opt
.) For example:
Please install java8 as package, e.g. for debian and then let cmake actually find jdk8:
and for the run-time, create the file /etc/ld.so.conf.d/java-8-oracle.conf
with the content (for amd64):
and run:
macOS includes an old apple specific version of java, based on 1.6. However, for the jni plugin version 1.8 of Java is required, so either the openjdk or the oracle jdk has to be installed.
Please install oracle's jdk8 via their provided installer. After that, you have to set the JAVA_HOME environment variable to the folder where the jdk is installed, usually like
As macOS handles linked libraries differently, there is no ldconfig command. Instead you can export an environment variable to tell elektra the location of the java dynamic libraries.
Afterwards, the jni plugin should be included in the build and compile successfully.
If it should still not find the correct jni version, or says the jni version is not 1.8, then it most likely still searches in the wrong directory for the jni header file. It has been experienced that if the project has been built already without this environment variable set, the java location is cached. As a result, it will be resolved wrong in future builds, even though the environment variable is set. To resolve this, it should be enough to delete the CMakeCache.txt file in the build directory and reconfigure the build.
Then enable the plugin using (ALL;-EXPERIMENTAL
is default):
Running
should work then (needs BUILD_FULL cmake option), if you get one of these:
You missed one of the ldconfig steps.
You need to pass :
elektra/plugin/Echo
Additionally, you can set:
-verbose:gc,class,jni
false
E.g.
Or if .jar
is already installed:
Additionally, the java implementation can request any other additional configuration, read about it below in the section (specific java plugin). If you are reading this page on GitHub, you won't see it, because the plugins dynamically append text after the end of this page.
To know how the methods of your class are called, use:
Also explained here
Argumentation for discouraged: