LuaJ 在 Java 中引用 json 模块。

我试图在Java代码中加载json模块。文档中的示例显示应该像此示例一样,但并不起作用。它需要模块在项目中还是从LUA_PATH中加载模块?有没有人有这个问题的经验?

Globals globals = JsePlatform.standardGlobals();
globals.get("require").call( LuaValue.valueOf("json") );

Exception in thread "main" org.luaj.vm2.LuaError: module 'json' not found: json no field package.preload['json'] json.lua no class 'json'

看起来它只是在LuaJ包中尝试。

点赞
用户2279620
用户2279620

如果你使用的json模块是使用lua编写的,那么它将需要像其他lua模块一样在package.path中。

如果它是使用java编写的,那么LuaJ将需要能够在正常的Java类路径中找到json.class。

2014-01-27 11:37:51