This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to watch file directory tree w/o poling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How to watch file directory tree w/o poling" Watch "How to watch file directory tree w/o poling" New topic
Author

How to watch file directory tree w/o poling

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 396
How does the JBoss server detect when I drop a new WAR or EAR file into the drop directory? I noticed that JBoss (and I think other EJB containers) automagically expands a EAR/WAR file when it appears. Does it poll for new files?

I hope not. Windows has a function that allows C++ programmers to specify a call back function whenever there is a modification in the specified directory. I imagine linux/freebsd has this function too? I hope so.

Anyway, how can I write a java program that does not poll the file modification times to detect a new or modified file or directory? Can I do it with out JNI/C? I hope so.
Thanks,
Siegfried
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3986
    
  18

Not without writing native code.

I believe Java 7 will provide this feature, but you'll have to wait for it.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10744
    
    9

Check out JNotify


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

Stephan van Hulst wrote:I believe Java 7 will provide this feature, but you'll have to wait for it.

It will, with java.nio.file.WatchService, but that too may use polling internally if the file system doesn't support notifications.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How to watch file directory tree w/o poling
 
It's not a secret anymore!