kohlschutter / junixsocket

Unix Domain Sockets in Java 7 and newer (AF_UNIX), AF_TIPC, AF_VSOCK, and more
Apache License 2.0
438 stars 114 forks source link

Request a tutorial #18

Closed Hesam-Naderi-Dehkordi closed 5 years ago

Hesam-Naderi-Dehkordi commented 9 years ago

Hi there. I was searching a good tutorial on how to use your library, but didn't find anything. I'm new to JNI and don't know how to use your library. I have .jar files of your library but when trying to import and use them I get some errors like this : Exception in thread "main" java.lang.NoClassDefFoundError: org/scijava/nativelib/JniExtractor at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.newsclub.net.unix.NativeUnixSocket.(NativeUnixSocket.java:35) at org.newsclub.net.unix.AFUNIXServerSocket.(AFUNIXServerSocket.java:51) at org.newsclub.net.unix.AFUNIXServerSocket.newInstance(AFUNIXServerSocket.java:63) at org.newsclub.net.unix.demo.SimpleTestServer.main(SimpleTestServer.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: java.lang.ClassNotFoundException: org.scijava.nativelib.JniExtractor at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 11 more

Process finished with exit code 1

kohlschuetter commented 5 years ago

We're getting rid of JniExtractor in 2.1. Also there's now better documentation on https://kohlschutter.github.io/junixsocket/

shubham643 commented 5 years ago

Hi kohlschuetter, I am also facing this exactly same error. Can you please let me know about how to resolve this?

kohlschuetter commented 5 years ago

This is fixed in junixsocket 2.1. Please try to upgrade to 2.1.2. If you're using Maven, make sure you add junixsocket-core and junixsocket-common as the dependencies.

shubham643 commented 5 years ago

Is it that 2.1.2 is not using any native library? I somehow fixed jniextractor issue but got stuck at connectto method in NativeUnixSocket class

kohlschuetter commented 5 years ago

junixsocket 2.1 no longer uses JniExtractor to load the native library. We now have a custom native library loader.