问题
I'm trying to setup jnotify in a centos 5.4 (64 bit) box to monitor directories for file change. I followed the instruction by putting the libjnotify.so in java library path. Here's my entry
java -Xms64m -Xmx2048m -Djava.library.path=. -Dfile.encoding=UTF-8 -jar test-1.1.0.jar
When I try to execute it, I'm getting the following exception
Exception in thread "main" java.lang.UnsatisfiedLinkError: /root/testprocessor/libjnotify.so: /lib64/libc.so.6: version `GLIBC_2.12' not found (required by /root/testprocessor/libjnotify.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at net.contentobjects.jnotify.linux.JNotify_linux.(Unknown Source)
at net.contentobjects.jnotify.linux.JNotifyAdapterLinux.(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at net.contentobjects.jnotify.JNotify.(Unknown Source)
The error certainly points to missing library 'GLIBC_2.12' in CentOS. Just wanted to know if anyone faced similar issues ?
Any pointer on this will be highly appreciated.
Thanks
回答1:
Ok, resolved it with the help of a CentOS geek. Just thought of sharing the answer if anyone encounters a similar issue.
You can upgrade your CentOS version to 6.* to get the GCLIB_2.12 and above.
If you are in my situation where version upgrade is not an option, you need create a libjnotify.so and remove the dependency on GCLIB_2.12. Here's what you need to do by checking out jNotify source code.
cd ~/compile
mkdir jnotify
cd jnotify
unzip ~/downloads/jnotify-lib-0.94.zip
mkdir src
cd src
unzip ../jnotify-native-linux-0.94-src.zip
cd Release
export C_INCLUDE_PATH=/usr/java/jdk1.7.0_07/include/:/usr/java/jdk1.7.0_07/include/linux/
make
This will generated libjnotify.so , copy it to you java library path and restart the jar file. It should resolve the issue.
来源:https://stackoverflow.com/questions/12628203/issue-with-running-jnotify-in-linux-centos-5-4