启动项目jnotify报错问题

java.lang.UnsatisfiedLinkError: no jnotify in java.library.path net.contentobjects.jnotify.linux.JNotify_linux.(Unknown Source)报错问题

在重启原先的一个项目时,发现启动报如下错误

Exception in thread “Thread-3” java.lang.UnsatisfiedLinkError: no jnotify in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
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:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:379)
at net.contentobjects.jnotify.JNotify.(Unknown Source)
at com.javamalls.system.StaticResourceListener.jnofity(StaticResourceListener.java:49)
at com.javamalls.system.StaticResourceListener.run(StaticResourceListener.java:33)
at java.lang.Thread.run(Thread.java:745)

这个问题是因为linux系统下缺少JNotify的链接文件所致,JNotify在windows系统下的链接文件为jnotity.dll(需要注意64位系统为jnotity_64.dll文件)。而在linux系统下,链接文件则是后缀为so的文件。于是下载 JNotify的jar,地址为https://sourceforge.net/projects/jnotify/files/
在这里插入图片描述
打开下载下来的jnotify-lib-0.94.zip文件,发现有个 libjnotify.so文件
在这里插入图片描述
正是linux系统下的java library path 中缺少 libjnotify.so 所致,需要注意如果是64位系统则要64-bit Linux目录里的libjnotify.so。(执行 getconf LONG_BIT 命令可以查看机器是32位还是64位)。
将所需的 libjnotify.so 文件复制到 对应的 java library path 下即可。那么如何找到java library path所在位置呢?

打印出当前的java.library.path:

执行 vi Test.java

切换编辑模式 i

插入如下代码:

public class Test {
public static void main(String[] args) {
System.out.println(“java.library.path:-----------”);
System.out.println(System.getProperty(“java.library.path”));
}
}
退出编辑 ESC

保存并退出 :wq

执行javac Test.java

执行 java Test

返回:

在这里插入图片描述
libjnotify.so 复制到 /usr/lib64下,重启项目就正常启动了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值