Is it possible to load the Teamspeak.so library by System.loadLibrary
in java and access the methods declared in the .h files?
(sources are the files from the ts3_sdk_3.0.3.2 - .h files from /include/teamspeak/serverlib.h; .so files from /bin/libts3server_linux_amd64.so)
Im able to load the library:
System.loadLibrary("ts3server_linux_amd64");
- works without error.
When i try to use a method i get a
java.lang.UnsatisfiedLinkError
Testcode:
public class main {
static {
System.loadLibrary("ts3server_linux_amd64");
}
public static void main(String[] args) {
new main().onClientStartTalkingEvent();
}
private native void onClientStartTalkingEvent();
}
(.so file is stored in a lib folder and added to the classpath. OS is ubuntu).
Thanks and best regards
Instead of loading the teamspeak .so you need to load the .so of your JNI code (which links against the teamspeak .so).
Edit
To call a native library from Java you need to write a JNI wrapper. This is a native library itself which you have to load from Java and can be called through
native
functions. If the native library you want to call is C (and not C++) you can have a look at projects like jnr-ffi or jna. These allow you to call C libraries without having to write a JNI wrapper.