Intergrate jar file into ionic project


#1

Hey there,

I’m developing an app (Ionic v3) with a chatbot using AIML. My project goal: The chatbot should ask questions and the user have to answer. But I’ve one big problem: There’s no working AIML-Interpreter. There’s only ProgramAB as a jar file and I’ve found this tutorial to work with ProgramAB in java.
My plan: I’ve tried to integrate this jar file into my projekt as a cordova plugin like this…

plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="aiml-interpreter" version="1.0.0">
    <name>AIML Interpreter</name>
    <description></description>
    <license>MIT</license>
    <keywords></keywords>

    <js-module src="www/plugin.js" name="plugin">
        <runs/>
        <clobbers target="AIMLInterpreter" />
    </js-module>

    <!-- android -->
   
    <platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="AIMLInterpreter">
                <param name="android-package" value="com.example.AIMLInterpreter" />
                <param name="onload" value="true" />
            </feature>
        </config-file>
        <source-file src="src/android/libs/aiml-plugin.jar" target-dir="src/com/example/" />
    </platform>
</plugin>

and in config.xml

<lib-file src="plugins/aiml-plugin/src/android/libs/aiml-plugin.jar"/>

…and now - I’m honest - I’ve no idea what to do next. What should I write into the plugin.js and the chat.ts files? Can anyone help me?

Rim


#2

Hi,

See: https://github.com/dpa99c/cordova-plugin-hello-c

And, in particular: https://github.com/dpa99c/cordova-plugin-hello-c/tree/master/src/android

It demonstrates how you can use Cordova’s plugin architecture to access Java (and ‘C’) from JavaScript.

Cheers
Rob