Scala language binding lightly-tested and works

This commit is contained in:
Joseph Henry
2017-10-16 14:27:25 -07:00
parent 7c04472b68
commit e8f1a4db73
5 changed files with 14 additions and 76 deletions

View File

@@ -0,0 +1,11 @@
import zerotier.ZeroTier
object ExampleApp extends App {
System.loadLibrary("zt")
val libzt = new ZeroTier
libzt.ztjni_startjoin("/Users/joseph/op/zt/libzt/ztjni", "1212121212121212")
val fd = libzt.ztjni_socket(2, 1, 0)
println(s"zts_socket(): $fd")
}

View File

@@ -6,7 +6,7 @@ To get this example project to work, do the following:
- From libzt main directory, build shared library: `make shared_jni_lib`
- Copy the resultant dynamic library (`*.so` or `*.dylib`) from `build/` to this current directory
- Change to this directory and `make example_scala_app`
- Run: `scala -cp "." ExampleApp`
- Run: `scala -Djava.library.path=$(pwd) -cp "." ExampleApp`
Notes:

View File

@@ -1,13 +1,6 @@
package zerotier;
class ZeroTier {
@native def ztjni_socket(socket_family: Int, socket_type: Int, protocol: Int): Int
@native def ztjni_startjoin(path: String, nwid: String): Int
}
object ZeroTier extends App {
System.loadLibrary("zt")
val libzt = new ZeroTier
val fd = libzt.ztjni_socket(2, 1, 0)
println(s"zts_socket(): $fd")
}