Frage

So I got this java file which loads a .lua file. Pretty basic and it works if I try to run it in Eclipse.

Now when I compile the project in a runnable jar file it wont load at all. When you double click it, it just loads and stops.

I tried multiple jar compile options but it doesn't seem to work though.

import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.JsePlatform;

public class SampleJseMain {

    public static void main(String[] args) throws Exception {
        String script = "main.lua";

        // create an environment to run in
        LuaValue _G = JsePlatform.standardGlobals();
        _G.get("dofile").call( LuaValue.valueOf(script) );
    }
}

And the Lua main file:

delay = 100000
while delay > 1 do
  print( 'hello, world' )
  delay = delay - 1
end
War es hilfreich?

Lösung

I would guess that it cannot find your lua script. Where is your lua script relative to your Jar. And perhaps you should run the jar from the command line. Also, add some diagnostic prints or something so you have a better idea of what is going on.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top