1

I've been searching for this for hours now: I have a lua script with variables I'd like to add to a java program. Is there an other way than using luajava (which I tried to set up with no luck), or something like write to a text file than read from it with java?

What I want, is: run a lua thread and a java thread and read data from the lua thread and use it in the java thread.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Ferenc Dajka
  • 1,052
  • 3
  • 17
  • 45
  • 1
    How about tcp sockets? Or, running your Lua script in Java implementation of Lua? – GreyBeardedGeek Nov 30 '12 at 16:52
  • 1
    Possible duplicate of http://stackoverflow.com/questions/2113432/how-can-i-embed-lua-in-java – lhf Nov 30 '12 at 16:56
  • If you show what problems you had setting up luajava, you can get help setting that up. – Mud Nov 30 '12 at 16:59
  • no what i want, is: run a lua thread and a java thread and read data from the lua thread and use it in the java thread. I've installed luaJ I can run lua scripts with that thought I'm not sure I know what I'm doing. LuaJava: the problem was, that I couldn't find the VCVARS32.BAT, I installed msvc++, reinstalled it, I just could not get it work – Ferenc Dajka Nov 30 '12 at 19:44
  • @FerencDajka: Please edit your question. – Martin Schröder Dec 01 '12 at 11:39

1 Answers1

2

An alternative way to connect Lua and Java is jnlua.

In contrast to LuaJava, it has several advantages - it handles Java arrays, provides specialized __ipairs and __pairs metamethods for List and Map derivates, __tostring using toString(), __eq using equals() and __lt when an object implements Comparable.

Note that jnlua 1.0 requires Lua 5.2, if you only have Lua 5.1 you have to use jnlua 0.9.

Michal Kottman
  • 16,375
  • 3
  • 47
  • 62