在linux中运行jNotify的问题(​​CentOS 5.4)

时间:2012-09-27 18:51:59

标签: java centos5 jnotify

我正在尝试在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'。只是想知道是否有人遇到过类似的问题?

任何指针都将受到高度赞赏。

由于

1 个答案:

答案 0 :(得分:4)

好的,在CentOS极客的帮助下解决了这个问题。如果有人遇到类似的问题,只想分享答案。

  1. 您可以将CentOS版本升级到6. *以获得GCLIB_2.12及以上版本。

  2. 如果您处于不支持版本升级的情况,则需要创建 libjnotify.so 并删除对 GCLIB_2.12 的依赖关系。通过查看jNotify源代码,您需要执行以下操作。

  3. 
    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文件。它应该解决这个问题。