diff --git a/README.html b/README.html index 6ad3c359..7c9ff6bd 100644 --- a/README.html +++ b/README.html @@ -31,6 +31,10 @@ Freely available under the terms of the examples · concepts +· +libraries +· +building
@@ -164,41 +168,6 @@ A working example may be found in -
-To include the luajava library, include a line in your script such as: - -
- require( "org.luaj.lib.j2se.Luajava" ) -- -
-or include the following line in your startup code: - -
- org.luaj.lib.j2se.Luajava.init( vm._G ); -- -
-See the following example for more details: -
- src/sample/LuajavaRunner.java -- -
-Because reflection is required by the implementation, this is only usable from the J2SE platform. - -
-You must include the library lib/luaj-j2se-${VER}.jar in your class path. - -
-You can try sample code that creates a simple Swing UI using: -
- java -cp luaj-j2se-${VERS}.jar lua src/test/res/swingapp.lua
-
-
-
The following libraries are loaded by default in J2ME and J2SE platforms:
@@ -229,39 +205,84 @@ The following libraries are loaded by default in J2ME and J2SE platforms: table-In addition, J2SE contains these two libraries: -
++The following libraries are optional, but preconfigured for some platforms and tools: +
io - luajava + debug + luajava-See standard lua documentation for details on the library API's +The following is not yet implemented: ++ os ++ +Optional Libraries
+ +I/O Library
+The J2SE platform contains the io library by default.-There is a partial implementation of the io for J2ME in +The J2ME platform has an optional, partial implementation of the io in
src/j2me/org/luaj/lib/j2me/Cldc10IoLib.java-See the sample midlet to see how it is added to a platform. -The Luajava Library
-The luajava library implements a few functions which allow access to most classes -within the host J2SE runtime. They are included as part of the standard J2SE platform. - -LuaJava
-The luajava library is used to easily bind to Java classes via reflection. -It is patterned after the original luajava project. - -Because J2ME does not contain a reflection API, this library cannot be made to work on J2ME, -and is not included by default. - -Unimplemented Libraries
-The following libraries are not yet implemented: +To install into your vm instance use (j2me only): ++ LuaState vm = Platform.newLuaState(); + org.luaj.lib.j2me.Cldc10IoLib.install(vm._G); ++ ++See the sample midlet int src/sample/SampleMIDlet for an example. + +
Debug Library
+The following library is optional:- os debug+Install from Java using: ++ LuaState vm = Platform.newLuaState(); + org.luaj.lib.DebugLib.install(vm); ++ +or install from lua using: ++ require 'org.luaj.lib.DebugLib' ++ +The lua command line utility includes the debug library by default. + + +The Luajava Library
+The J2SE platform includes the luajava library, which simplifies binding to Java classes and methods. +It is patterned after the original luajava project. + ++The following lua script will open a swiing frame on J2SE: +
+ jframe = luajava.bindClass( "javax.swing.JFrame" ) + frame = luajava.newInstance( "javax.swing.JFrame", "Texts" ); + frame:setDefaultCloseOperation(jframe.EXIT_ON_CLOSE) + frame:setSize(300,400) + frame:setVisible(true) ++ ++See a longer sample in src/test/res/swingapp.lua for details, or try running it using: +
+ java -cp luaj-j2se-${VERS}.jar lua src/test/res/swingapp.lua ++ ++The J2ME platform does not include this library, and it cannot be made to work because of the lack of a reflection API in J2SE. + +
4 - Building and Testing
+Building the jars
An ant file is included in the root directory which builds the libraries by default. diff --git a/src/sample/org/luaj/sample/SampleJ2seMain.java b/src/sample/org/luaj/sample/SampleJ2seMain.java index c23bbeea..a28b3f10 100644 --- a/src/sample/org/luaj/sample/SampleJ2seMain.java +++ b/src/sample/org/luaj/sample/SampleJ2seMain.java @@ -8,6 +8,8 @@ public class SampleJ2seMain { String script = (args.length>0? args[0]: "src/test/res/swingapp.lua"); Platform.setInstance( new J2sePlatform() ); LuaState vm = Platform.newLuaState(); + // uncomment to install the debug library + // org.luaj.lib.DebugLib.install(vm); org.luaj.compiler.LuaC.install(); vm.getglobal( "dofile" ); vm.pushstring( script );