我正在尝试在 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 文件。应该可以解决问题。
关于java - 在 Linux (CentOS 5.4) 中运行 jNotify 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12628203/