문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top