I want to run shell script inside watch service class to run the shell after new file add to folder.
Watch service is working perfectly but when I want to add Runtime.getRuntime().exec("home/user/test.sh")
; I recived error.
I just add Runtime after this:
// Dequeueing events
Kind<?> kind = null;
for(WatchEvent<?> watchEvent : key.pollEvents()) {
// Get the type of the event
kind = watchEvent.kind();
if (OVERFLOW == kind) {
continue; //loop
} else if (ENTRY_CREATE == kind) {
// A new Path was created
Path newPath = ((WatchEvent<Path>) watchEvent).context();
// Output
System.out.println("New path created: " + newPath);
Runtime.getRuntime().exec("home/user/test.sh")
What I have to do?