Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Lua Development Tools » [LDT 1.0] load a module written in Java
[LDT 1.0] load a module written in Java [message #1273956] Thu, 20 March 2014 20:03 Go to next message
Baiqian Zhang is currently offline Baiqian Zhang
Messages: 2
Registered: March 2014
Junior Member
I met a problem when I tried to load a module written in Java.
Such as:
require 'Hyperbolic'

I followed the instruction from LuaJ, adding Hyperbolic to classpath. And I can do it in command line, like:
java -cp someDirectory lua HyperbolicApp.lua

However I don't know how to do it in LDT. There is no "ClassPath" in the "Run Configuration".
Please help me.
Re: [LDT 1.0] load a module written in Java [message #1277849 is a reply to message #1273956] Wed, 26 March 2014 14:49 Go to previous message
Simon Bernard is currently offline Simon Bernard
Messages: 287
Registered: July 2009
Senior Member
Hi

To use LuaJ as interpreter you should create a new "Lua Generic".(Windows/Preferences/Lua/Interpreter)

as interpreter executable, your "java" executable.
as interpreter arguments, this big line Smile :
-cp "/home/sbernard/Dev/juaj/luaj-3.0-beta2/lib/luaj-jse-3.0-beta2.jar" lua -e "local system = luajava.bindClass('java.lang.System'); local luapath = system:getenv('LUA_PATH'); if luapath then package.path=luapath end;"

Explication :
-cp "/home/sbernard/Dev/juaj/luaj-3.0-beta2/lib/luaj-jse-3.0-beta2.jar"
==> to add the luaJ jar to the classpath
lua 
==> to use the lua script engine registered by luaj
-e "local system = luajava.bindClass('java.lang.System');
local luapath = system:getenv('LUA_PATH');
if luapath then package.path=luapath end;" 
==> This lines of code is to workarround the fact that luaJ does not implement os.getenv correctly, it use System.getProperties instead of System.getenv. It's look like a bug.


With this you should run your lua script with luaj interpreter but not debug it :/.

I you want to debug, it should be possible but you need to write some code.
(I never test this so maybe, this will not works)

you should hack luaJ(I mean modify the code):

  • fix the getenv function in OsLib.java
  • the _VERSION global var should return "Lua 5.1" or "Lua 5.2" (see public static final String _VERSION = "Luaj 0.0" in Lua.java;
  • you could fix the DEFAULT_LUA_PATH in PackageLib to use getenv instead too


Then you should implement your own transport interface based on your luasocket for our debugger (see the interface and the transport parameter)

Previous Topic:Is somebody home??
Next Topic:Parsing files not commented in luadocs
Goto Forum:
  


Current Time: Wed Oct 22 08:21:20 GMT 2014

Powered by FUDForum. Page generated in 0.11824 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software