JNotify Error Exception Violation

I am trying to implement JNotify. but I get a little strange error messages when I compiled the program. I get sample code from this site ttp: //jnotify.sourceforge.net/sample.html

as information, JNotify is used to monitor directories, and this is what my source code looks like.

this is the contents of the watch.java class

import net.contentobjects.jnotify.JNotifyListener; import net.contentobjects.jnotify.JNotify; public class watching{ public void watching(String s) throws Exception { // path to watch String path = System.getProperty(s); // watch mask, specify events you care about, // or JNotify.FILE_ANY for all events. int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED | JNotify.FILE_MODIFIED | JNotify.FILE_RENAMED; // watch subtree? boolean watchSubtree = true; // add actual watch int watchID = JNotify.addWatch(path, mask, watchSubtree, new Listener()); // sleep a little, the application will exit if you // don't (watching is asynchronous), depending on your // application, this may not be required Thread.sleep(1000000); // to remove watch the watch boolean res = JNotify.removeWatch(watchID); if (!res) { // invalid watch ID specified. } } class Listener implements JNotifyListener { public void fileRenamed(int wd, String rootPath, String oldName, String newName) { print("renamed " + rootPath + " : " + oldName + " -> " + newName); } public void fileModified(int wd, String rootPath, String name) { print("modified " + rootPath + " : " + name); } public void fileDeleted(int wd, String rootPath, String name) { print("deleted " + rootPath + " : " + name); } public void fileCreated(int wd, String rootPath, String name) { print("created " + rootPath + " : " + name); } void print(String msg) { System.err.println(msg); } } } 

then this is the main class called nowwatch.java

 public class nowwatch { public static void main(String[] args) throws Exception { System.out.println("Hello World!"); watching hello = new watching(); hello.watching("C:/Users/Raden/Documents/Downloads"); } } 

but why did the error go like this? I had a screenshot of the error so you can see it by clicking on the link

Have any of you ever experienced this type of error? any help would be appreciated though. thanks

+3
source share
3 answers

JNotify, of course, uses JNI to interact with OS-specific notification APIs. Sounds like a bug in JNotify. Did you ask to ask on the JNotify forum on SourceForge?

+2
source

We had the same problems. Since we used JNA anyway, we just used the FileMonitor example from this structure. It works like a charm.

0
source

it asks for the jNotify.dll file, make sure you put this file in a window or in jre / bin or jdk / bin. and then try, it will start working.

0
source

Source: https://habr.com/ru/post/1396611/


All Articles