Embedding the Lua shell into a Java Application (LuaJava)

977 Views Asked by At

I am working on a app, It has a GUI (But not Java swing and JFrame stuff) I want to incorporate the Lua shell into the GUI. LuaJava doesn't have good documentation (or atleast for me) on how to do this.

2

There are 2 best solutions below

1
On

You'll probably have to write the 'shell' part yourself (in java), then pass the typed input to the embeded interpret (LuaJava, I suppose).

Maye java-readline could help.

0
On

I have used both LuaJ and Kahlua to do this. Works great with either one (they are roughly the same codebase) LuaJ has more complete implementations of the Lua standard libraries.

enter image description here

You can see on the right, I added an interactive Lua console to my IDE.

All my source is here: https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home

Actually, all you really need are the sources here:

https://bitbucket.org/sylvanaar2/lua-for-idea/src/770c80f12c11/src/kahlua

Here is an example of exposing an API to Lua, and calling Lua functions from Java.

https://bitbucket.org/sylvanaar2/lua-for-idea/src/770c80f12c11/src/lang/documentor/KahluaPluginDocumentationProvider.java