Add sample startup code for j2se

This commit is contained in:
James Roseborough
2008-12-03 06:07:29 +00:00
parent 485c95bc80
commit b639a3ca3e
2 changed files with 29 additions and 3 deletions

View File

@@ -14,7 +14,6 @@
<h1> <h1>
<a href="README.html"><img src="http://sourceforge.net/dbimage.php?id=196139" alt="" border="0"></a> <a href="README.html"><img src="http://sourceforge.net/dbimage.php?id=196139" alt="" border="0"></a>
Add Multimedia Data
Getting Started with LuaJ Getting Started with LuaJ
</h1> </h1>
@@ -76,8 +75,9 @@ The following pattern is used within J2SE
import org.luaj.vm.*; import org.luaj.vm.*;
String script = "main.lua"; String script = "main.lua";
Platform.setPlatform( new J2sePlatform() ); Platform.setInstance( new J2sePlatform() );
LuaState vm = Platform.newLuaState(); LuaState vm = Platform.newLuaState();
org.luaj.compiler.LuaC.install();
vm.getglobal( "dofile" ); vm.getglobal( "dofile" );
vm.pushstring( script ); vm.pushstring( script );
vm.call( 1, 0 ); vm.call( 1, 0 );
@@ -86,6 +86,12 @@ The following pattern is used within J2SE
<p> <p>
You must include the library <b>lib/luaj-j2se-${VER}.jar</b> in your class path. You must include the library <b>lib/luaj-j2se-${VER}.jar</b> in your class path.
<p>
A working example may be found in
<pre>
src/sample/SampleJ2seMain.java
</pre>
<p> <p>
Additional usage may be found in Additional usage may be found in
<pre> <pre>
@@ -102,8 +108,9 @@ The following pattern is used within MIDlets:
import org.luaj.vm.*; import org.luaj.vm.*;
String script = "main.lua"; String script = "main.lua";
Platform.setPlatform( new J2mePlatform() ); Platform.setInstance( new J2meMidp20Cldc11Platform( midlet ) );
LuaState vm = Platform.newLuaState(); LuaState vm = Platform.newLuaState();
org.luaj.compiler.LuaC.install();
vm.getglobal( "dofile" ); vm.getglobal( "dofile" );
vm.pushstring( script ); vm.pushstring( script );
vm.call( 1, 0 ); vm.call( 1, 0 );
@@ -128,6 +135,9 @@ but before the script is executed:
org.luaj.compiler.LuaC.install(); org.luaj.compiler.LuaC.install();
</pre> </pre>
<p>
To omit the compiler, omit this line from your startup code.
<h2>Run a script using JSR-233 Dynamic Scripting</h2> <h2>Run a script using JSR-233 Dynamic Scripting</h2>
<p> <p>

View File

@@ -0,0 +1,16 @@
package org.luaj.sample;
import org.luaj.platform.*;
import org.luaj.vm.*;
public class SampleJ2seMain {
public static void main(String[] args) {
String script = (args.length>0? args[0]: "src/test/res/swingapp.lua");
Platform.setInstance( new J2sePlatform() );
LuaState vm = Platform.newLuaState();
org.luaj.compiler.LuaC.install();
vm.getglobal( "dofile" );
vm.pushstring( script );
vm.call( 1, 0 );
}
}