How to run scripts in Lua with java program?

Asked

Viewed 363 times

0

I want to learn how to develop, combining more than one programming language, using java with scripts in moon.

1 answer

1


The Luaj offers a very simple integration interface between Java and Lua.

import org.luaj.vm2.*;
import org.luaj.vm2.lib.jse.*;

Globals globals = JsePlatform.standardGlobals();
LuaValue chunk = globals.loadfile("examples/lua/hello.lua"); // seu script lua
chunk.call();

You can save the value returned from chunk.call() in a variable. This is the result of the script executed. Source

The Luaj is fully open source and is on Github.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.