Loading user-defined java classes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Loading user-defined java classes

Thermo
I see you can load standard java classes by doing for example: local System = require "java:java.lang.System".

Is it possible to load user-defined java classes that are in the same directory as the luan file? I tried doing require "java:MyClass" and require "java:./MyClass" but neither of these seem to work.

My ultimate goal is to be able to call functions from a third-party java library.
Reply | Threaded
Open this post in threaded view
|

Re: Loading user-defined java classes

fschmidt
Administrator
Luan can load whatever is in the classpath.  It just uses Class.forName() .  In other words if 'import X;' works in java then 'require "java:X"' will work in luan.
Reply | Threaded
Open this post in threaded view
|

Re: Loading user-defined java classes

Thermo
Ok, I got it working by doing "export CLASSPATH=$CLASSPATH:~/site"