org.luaj.vm2.lib.jse
Class LuajavaLib
java.lang.Object
VarArgFunction
org.luaj.vm2.lib.jse.LuajavaLib
public class LuajavaLib
- extends VarArgFunction
Subclass of LibFunction which implements the features of the luajava package.
Luajava is an approach to mixing lua and java using simple functions that bind
java classes and methods to lua dynamically. The API is documented on the
luajava documentation pages.
Typically, this library is included as part of a call to
JsePlatform.standardGlobals()
Globals globals = JsePlatform.standardGlobals();
System.out.println( globals.get("luajava").get("bindClass").call( LuaValue.valueOf("java.lang.System") ).invokeMethod("currentTimeMillis") );
To instantiate and use it directly,
link it into your globals table via Globals#load using code such as:
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new LuajavaLib());
globals.load(
"sys = luajava.bindClass('java.lang.System')\n"+
"print ( sys:currentTimeMillis() )\n", "main.lua" ).call();
The luajava library is available
on all JSE platforms via the call to JsePlatform.standardGlobals()
and the luajava api's are simply invoked from lua.
Because it makes extensive use of Java's reflection API, it is not available
on JME, but can be used in Android applications.
This has been implemented to match as closely as possible the behavior in the corresponding library in C.
- See Also:
LibFunction,
JsePlatform,
org.luaj.vm2.lib.jme.JmePlatform,
LuaC,
CoerceJavaToLua,
CoerceLuaToJava,
http://www.keplerproject.org/luajava/manual.html#luareference
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LuajavaLib
public LuajavaLib()
invoke
public Varargs invoke(Varargs args)
classForName
protected java.lang.Class classForName(java.lang.String name)
throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
Copyright © 2007-2013 Luaj.org. All Rights Reserved.