Is LuaJava a must for this? Or can I embed Lua into Java without it?
Asked
Active
Viewed 6.5k times
55
-
4I'm guessing that you'd prefer a pure-Java implementation of Lua (instead of LuaJava which uses native bits)? Or are you just looking for any alternative implementation? – ZoogieZork Jan 21 '10 at 22:47
-
1A pure java implementation of LUA simply does not exist, and probably will never exist. It is a "C" project, and porting *all* that C to code java would be a huge undertaking, and I doubt the LUA authors see much benefit to that. – deltamind106 Aug 15 '18 at 20:43
-
@deltamind106 actually most of the work is already done, about 10 years ago I [ported the entire Lua 5.1.4 package to C#](https://github.com/Myndale/KopiLua) (and yes, it was a huge undertaking). A port from that to Java would, I imagine, be considerably easier. – Mark Feldman Sep 16 '20 at 11:40
4 Answers
30
LuaJ is easy to embed in Java. I did have to change a few lines of their source to get it to work how I expected (it didn't require the IO library automatically).

Ben Ziegler
- 431
- 4
- 3
-
I'm having a similar problem using Kahlua from IntelliJ. I am brand new to Lua and getting tripped up over an error, "attempted index of non-table" whenever I call "io.read()". I tried to require "io" but that doesn't work. Help? – Cliff Feb 03 '12 at 16:23
-
12
-
Kahlua now located [on github](https://github.com/krka/kahlua2), but not updated since 2013. Mochalua appears to have never been migrated off of Google Code, and is now archived; there are 4 versions on github, but none have been touched since 2015 and all just have the original 7 commits from the Google Code version from 2008-12-08. – Pixelstix Nov 16 '20 at 23:55
2
There is http://www.keplerproject.org/luajava/manual.html, but essentially lua is more suitable for integration with C. There are a bunch of other scripting languages with good java integration around though. Consider groovy, jruby or jython for starters.

Manfred Moser
- 29,539
- 13
- 92
- 123
-
2in this case I am stuck with lua otherwise I would go with jython being a python fan boy – Jan 21 '10 at 22:54
-
1
2
Lua is a C library, you can embed it in Java but you'll have to interface the java virtual machine and Lua with some C code.
The LuaJava authors have already done that work - you're better off using that than writing your own.

nos
- 223,662
- 58
- 417
- 506