我正在尝试在 centos 5.4(64 位)框中设置 jnotify 以监控目录的文件更改。我按照说明将 libjnotify.so 放在 java 库路径中。这是我的条目
java -Xms64m -Xmx2048m -Djava.library.path=. -Dfile.encoding=UTF-8 -jar test-1.1.0.jar
当我尝试执行它时,我收到以下异常
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)
该错误肯定指向 CentOS 中缺少库 'GLIBC_2.12'。只是想知道是否有人遇到类似的问题?
对此的任何指示将不胜感激。
谢谢
好的,在 CentOS 极客的帮助下解决了它。只是想在有人遇到类似问题时分享答案。
-
你可以将 CentOS 版本升级到 6.* 以获得 GCLIB_2.12 及以上版本。
-
如果您处于无法选择版本升级的情况下,则需要创建一个 libjnotify.so 并删除对 GCLIB_2.12 的依赖。以下是您需要通过查看jNotify源代码来执行的操作。
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
这将生成 libjnotify.so,将其复制到您的java库路径并重新启动jar文件。它应该可以解决问题。