Raw JNI too cumbersome? JNA not fast enough? C++ code generators make you sad?
Try Terra-Java!
Terra-Java leverages Terra's metaprogramming facilities to enable you to define native JVM extensions with unprecedented ease.
JNI boilerplate is automatically generated during Terra compilation.
Just as Terra can generate native code without a runtime Lua dependency, Terra-Java can generate JVM extensions without a Terra-Java dependency.
This project is a work-in-progress. Some things do not work as advertised yet.
Install Terra 2016-03-25 and the JDK, then set the following environment variables:
INCLUDE_PATH
: Terra looks here for standard C headers.JDK_HOME
: Terra-Java looks here for Java headers and libjvm.
To use Terra-Java from your own Terra project, add a pattern for the directory
containing terra-java.t
to one additional environment variable:
TERRA_PATH
: Terra's version ofLUA_PATH
. Use;;
for the default value.
For example:
TERRA_PATH=/some/path/to/terra-java/?.t;;
Compile the Terra-Java support libraries and examples:
./build.sh
Run Terra code that interops with the JVM:
terra ./terra-java/examples/interop.t
terra ./terra-java/examples/extension/native.t
Run JVM code that utilizes native extensions:
java \
-Djava.class.path=./obj \
-Djava.library.path=./obj \
terrajava.examples.extension.Accumulator
Check out the examples, then see the guide for many more details