Page 1 of 1

Call Java from C to call it from Lua

Posted: Sun Dec 08, 2013 4:20 pm
by BlubBlab
First I found a nice chatbot very advanced https://code.google.com/p/program-ab/ unfortunately the bot is in Java written
So I want is to use it in MM so seek possibles to bridge between Lua and Java.
First I found a lots of ways to use Lua in Java but that doesn't allow me to use it I want to call Java from Lua.

I found this http://www.codeproject.com/Articles/228 ... -Using-JNI a C/C++ API to do that.
I already found and complied https://github.com/jmckaskill/luaffi to call any foreign *.dll in Lua.

So the Pipe would be MM=>Lua=>FFI=>my.dll=>Java VM=>Chatbot

The problem I have is how I can save my Java VM Pointer, my C is little rusty but so far I remember I can't save anything(global var) in a *dll because it has no memory on its own. What is needed to save is struct so far I can see, anyone any idea?

Re: Call Java from C to call it from Lua

Posted: Sun Dec 08, 2013 9:32 pm
by Administrator
That seems overcomplicated and difficult.

It might instead be easier to write some bindings so that you can use functions from that library in Lua. Basically, you want to export a .DLL where the exposed functions are Lua callbacks. Now, just drop this into MicroMacro's plugin directory and you're done.