<commit_before>- infos = Information about the jni plugin is in keys below
- infos/author = Name <<EMAIL>>
- infos/licence = BSD
- infos/needs =
- infos/provides =
- infos/placements =
- infos/description =

# Generic Java plugin #

## Introduction ##

Allows you to write plugins in java.

Needs Java 8 or later. While the plugin internally uses JNI, the Java
binding for your java-plugin may use something different, e.g. JNA.
The requirements for the java bindings are:

- needs to have the classes elektra/Key and elektra/KeySet with
 - an constructor that takes a C-Pointer as long (J)
 - an method "release" that gives up ownership (set internal pointer to NULL)

The java plugin itself needs to have following methods:

- constructor without arguments (e.g. default constructor)
- open with argument elektra/KeySet (the plugin's conf) and elektra/Key
- close with argument elektra/Key
- get with arguments elektra/KeySet and elektra/Key
- set with arguments elektra/KeySet and elektra/Key
- error with arguments elektra/KeySet and elektra/Key

## Plugin Config ##

You need to pass :
- classname the classname to use as plugin, e.g. elektra/plugin/Echo
- classpath the classpath where to find JNA, the package elektra and
  other classes needed

Additionally, you can set:

- option allows you to pass a option to the jvm, default: -verbose:gc,class,jni
- ignore allows you to ignore broken options, default: false
- print allows you to print java exceptions for debugging purposes

E.g.

    kdb info -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/libelektra/src/bindings/jna,print= jni
    kdb check -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/libelektra/src/bindings/jna,print= jni
    kdb mount -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/src/bindings/jna,print= file.properties /jni jni classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/libelektra/src/bindings/jna,print=

Or if .jar is already installed:

    bin/kdb mount -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/share/java/elektra.jar,print= file.properties /jni jni classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/share/java/elektra.jar,print=

Additionally, the java implementation can request any other additional
configuration, read about it below in the section (specific java plugin).<commit_msg>link from manuel<commit_after>- infos = Information about the jni plugin is in keys below
- infos/author = Name <<EMAIL>>
- infos/licence = BSD
- infos/needs =
- infos/provides =
- infos/placements =
- infos/description =

# Generic Java plugin #

## Introduction ##

Allows you to write plugins in java.

Needs Java 8 or later. While the plugin internally uses JNI, the Java
binding for your java-plugin may use something different, e.g. JNA.
The requirements for the java bindings are:

- needs to have the classes elektra/Key and elektra/KeySet with
 - an constructor that takes a C-Pointer as long (J)
 - an method "release" that gives up ownership (set internal pointer to NULL)

The java plugin itself needs to have following methods:

- constructor without arguments (e.g. default constructor)
- open with argument elektra/KeySet (the plugin's conf) and elektra/Key
- close with argument elektra/Key
- get with arguments elektra/KeySet and elektra/Key
- set with arguments elektra/KeySet and elektra/Key
- error with arguments elektra/KeySet and elektra/Key



## Installation ##

Please install java8 as package, e.g.
[for debian](http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html)
and then let cmake actually find jdk8:

      cd /usr/lib/jvm/ && sudo ln -s java-8-oracle default-java

Then enable the plugin using:

    cmake -DPLUGINS="...;jna" /path/to/libelektra


## Plugin Config ##

You need to pass :
- classname the classname to use as plugin, e.g. elektra/plugin/Echo
- classpath the classpath where to find JNA, the package elektra and
  other classes needed

Additionally, you can set:

- option allows you to pass a option to the jvm, default: -verbose:gc,class,jni
- ignore allows you to ignore broken options, default: false
- print allows you to print java exceptions for debugging purposes

E.g.

    kdb info -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/libelektra/src/bindings/jna,print= jni
    kdb check -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/libelektra/src/bindings/jna,print= jni
    kdb mount -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/src/bindings/jna,print= file.properties /jni jni classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/lib/java:/path/to/libelektra/src/bindings/jna,print=

Or if .jar is already installed:

    bin/kdb mount -c classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/share/java/elektra.jar,print= file.properties /jni jni classname=elektra/plugin/PropertiesStorage,classpath=.:/usr/share/java/jna.jar:/usr/share/java/elektra.jar,print=

Additionally, the java implementation can request any other additional
configuration, read about it below in the section (specific java plugin).
{'fraction_non_alphanumeric': 0.10356104651162791, 'fraction_numerical': 0.0023619186046511626, 'mean_word_length': 4.247855100095329, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6507800', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1748, 'n_words': 540}