lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Check out the sample code on:
http://www.keplerproject.org/luajava/manual.html#javareference

That seems to be what you want, right? You can also evaluate strings
directly using e.g. loadstring. If you wanted to have the same interface
as the javax.script.ScriptEngine I suppose you could write a small
wrapper around it without too much difficulty.


I wrote a config class that loads its contents from file. The
constructor is pretty simple:

        public Config(File f) throws FileNotFoundException
        {
                configState_ = LuaStateFactory.newLuaState();
                configState_.doFile( f.getAbsolutePath() );
        }

then when I want to get a key, I can do things like pushString followed
by getTable to get the config table's value at that key.

Cheers,
- David

--
~David-Haley
http://david.the-haleys.org

I think your sample is the best way to integrate lua script in Java code. I try this  in order to see the list which supported by rhino engine :
import javax.script.* ;
import java.util.List;

public class Test
{
    public static void main (String[] args)
    {
        ScriptEngineManager sem = new ScriptEngineManager();
        List <ScriptEngineFactory> lsef = sem.getEngineFactories();
        ScriptEngineFactory seng = lsef.get(0);
        List <String> tab = seng.getNames();
        for (int i=0;i<=tab.size()-1;i++) { System.out.println(tab.get(i)); }
    }

}
And it print :

js
rhino
_javascript_
_javascript_
ECMAScript
ecmascript

So... I have to use your way.. Thanks a lot !


--
Frédéric ASTIC
06.25.91.07.04