问题标签 [jnotify]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
605 浏览

java - 使用 Jnotify 忽略文件修改

我正在使用Jnotify编写应用程序。(JNotify 是一个用于检测文件修改的库。)

该应用程序具有以下组件:

  1. 写入文件 X 的文件写入器

  2. 监视文件 X 的文件监视程序(使用 JNotify 创建)

  3. 根据用户要求写入文件 X 的外部应用程序(例如记事本)。

我希望 JNotify 仅在使用 3 修改 X 时触发通知,并在通过 1 修改时忽略。(或至少区分通过 1 和 3 进行的修改)。

有没有一种简单的方法可以做到这一点?一种方法是有一个同步变量,当文件编写器写入它时切换它,但我觉得这不是很优雅。

0 投票
3 回答
636 浏览

java - JNotify 和文件阅读器相互冲突

我实现了 JNotify 来确定新文件何时到达特定目录,并在文件到达时将文件名发送到另一个函数,如下所示:

函数 mp.processMessage 尝试打开该文件,但我不断收到错误消息,指出该文件正在被另一个进程使用。但是,由于该文件刚刚创建,唯一可能使用它的其他进程是 JNotify。

我放了几个打印语句,似乎函数 mp.processMessage 在侦听器的打印函数之前被调用。除了将整个消息处理放在侦听器类中之外,有没有人对我如何解决这个问题提出建议?

0 投票
0 回答
153 浏览

java - 用于文件系统的 Java API 更改?

可能重复:
Java 检测文件系统中的更改

任何人都可以建议使用 Java API 来跟踪 FileSystem 中的事件吗?我找到了一个 - JNotify,但它不支持 64 位系统。

此外,新的 java.nio.* 库在部署级应用程序中使用起来非常新,因为许多 JRE 还没有真正支持它。

一种替代方法是轮询 FS 以进行更改,我相信很多人都会这样做,但我的直觉表明这将非常耗费资源。

0 投票
1 回答
1032 浏览

java - 如何在 Linux(Ubuntu OS) 中配置 Jnotify?

我在 Windows 中使用过 Jnotify我在SYSTEM FOLDER 和SYSTEM32中复制了 DLL 文件, 并将 Jnotify.jar 包含在构建路径中。这个程序运行良好。我得到了 jnoitify 提供的 Windows 系统中的所有通知。

现在我希望 jnotify 在 Ubuntu Linux 中工作。请帮助我应该遵循什么程序。我在我的 java 类路径中包含了 Jnoitify.jar。但它不起作用。

通过遵循上述,以下异常来了。

0 投票
3 回答
1217 浏览

java - 使用 JNotify 库,您如何判断删除的文件是文件还是目录?

对于那些不熟悉JNotify的人来说,这是一个库,它提供了一种简单的方法来监视目录中的事件。

例如,当文件在选定的文件夹中删除时,将调用“ filedeleted”的方法以及一些参数。以下是 fileDeleted 方法的示例:

现在,我想知道删除的文件是文件还是目录。我常用的方法是使用给定的路径创建一个新的 File 对象,并使用方法 isFile() 和 isDirectory()

但是,由于该文件已被删除,因此这些方法总是返回 false。

所以这是我的具体问题:我有一个已删除文件或目录的路径,我如何判断它是文件还是目录?有解决方法吗?在这里最好的做法是什么?

先感谢您。

0 投票
2 回答
5589 浏览

java - JNotify 在 Mac OS X 上?

我想试试看文件系统变化的插件库 JNotify,但不知道如何配置它。JNotify 的网页说“java.library.path 应该指向 jnotify 附带的本机库的位置(dll,所以 dylibs 等)”。我对 Mac OS X 相当陌生,并不真正知道如何做到这一点。我正在使用 NetBeans,并希望有一种简单的方法可以将它添加到那里的路径中。我通过简单地将 jar 文件添加到项目中的 Libraries 节点并通过“import net.contentobjects.jnotify.*;”导入它来尝试它,但这没有帮助。我得到这个:

看来我还需要将本机库(我猜是 Mac 的 .so 文件)添加到同一路径中。

那么我该怎么做呢?

0 投票
2 回答
283 浏览

java - 由于 Jnotify 监视而无法移动文件

我正在使用 JNotify 来监视一个文件夹,只要有一个新文件进入该文件夹,我就需要解析该文件并将该文件移动到其他文件夹中,当它执行文件移动代码时“它是说被其他进程使用”。

由于该文件已被 JNotify 观看,因此我无法移动它。

请帮我一些想法。

0 投票
2 回答
595 浏览

java - 替代 JNotify?

我在 Windows 上使用了 JNotify。但我越来越奇怪了。

Java 运行时环境检测到意外错误:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) 在 pc=0x6d94200c,pid=22944,tid=20528

Java VM:Java HotSpot(TM) Client VM(1.6.0_01-b06 混合模式,共享) 问题帧:V [jvm.dll+0xd200c]

所以我想知道 JNotify 的一些替代品。API 看起来在文件系统中发生了变化,并且在 windows 和 linux 上运行良好。

0 投票
1 回答
472 浏览

java - Tomcat Servlet Jnotify directory monitoring

I want to create a servlet to be contained within Tomcat which uses Jnotify (probably but open to suggestions) to monitor a directory for changes.

I would use Java 7 and the NIO stuff but our production systems run Ubuntu 10.04 and I want to stick with stuff currently which is mostly in the repositories and in deb packages for deployment reasons.

My question concerns how I would integrate Jnotify into a my Tomcat servelts. My think at present is that I create a servlet using the GenericServlet class which in the init() method sets up the watch on the directories I want. I then somehow (this is the bit I don't understand) call the service() method when ever I get activity on the directory. I could then have a Listener which does an action on the directory (in this case moves files)

Or I could create a new protocol handler (e.g use PoolTcpEndpoint as a starting point), but its not a protocol so this seems stupid.

Or there is a better way? The only reason behind using Tomcat is that a lot of our other logic is held within our tomcat servers. If there is a way to Daemonise Java and get an event driven architecture in another fashion then I'm open minded, but I wouldn't want to do something like use Jetty for instance as this would be another piece of technology to add to the stack to support which isn't possible.

Look forward to hearing your thoughts.

Thanks

0 投票
1 回答
1967 浏览

java - 在 Mac OS X 上配置 JNotify

可能的重复

如何在 Mac OS X 上配置 Jnotify。我正在使用 MyEclipse 和最新版本的 Jnotify。我是 MAC OS 的新手,刚刚在我的 lib 路径中添加了 jnotify.jar。当我运行我的主要课程时。发生以下异常