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.
Hi all, I want to write a program that interacts with the file system, or rather with the events I suspect the file system raises when such things like a file is moved, or a new file created.
I know the basic form will be to have a system library that captures the events, and then via JNI "throws" them up to a java layer, where any processing can take place.
I was just wondering, as this strikes me as something a lot of people would want to do, is this already part of JNI, or will I have to learn to do some MFC programming in windows? (As my first target platform).
I would rather avoid writing windows code if possible, although, I can code in C# perhaps this would shield me from the horridness of C++/MFC.
Nothing is a part of JNI. JNI merely allows Java code to call on native shared libraries. I believe "MFC" refers more to the GUI programming library than file system routines. When I last did native stuff on Windows, the file system routines were in the Win32 API. The same functionality may be offered in .NET, so you may be able to get by with C#.
Thanks, I was hopeing that wouldnt be the answer, i was hopeing that Java had an API for working with FileSystem events, but then I guess if they provide one for the FileSystem, then other sub-systems of the OS will be demanded.
Originally posted by Gavin Tranter: Sorry for my bad use of technical terms.
We're all here to learn. And I could be wrong. My statements are based on my best memory of work I did years ago. You have to remember that Java is platform independent. File systems vary widely, even on a particular platform (Windows has FAT, FAT32, NTFS; *nix has several ext's, several Reiser's, xfs, zfs and many, many more). Sun took care of most of the common features and left the rest to the programmer. If all you are concerned about is watching a directory for new, changed and deleted files, do a search in the "Java In General" forums here. Lots of people have implemented similar things using a thread and the java.io.File class.
Joined: Jan 01, 2007
Hi, Yeah I understand that, but my use of JNI was rather broad and off the mark really, mad all the worse as I know what JNI is and have used it in the past. As to MFC well I just remember it as the class library to use to develop Windows application, that wasnt as well put together as OWL and in general to be avoid (Generally i think the writing of Windows apps outside of soemthing like delphi was to be avoided).
Yeah I dont really think the thread method is inappropriate as I want to "watch" the whole file system.
Basicly I am sick of the current file mangers you get with windows (not sure about vista, I dont want to even look at vista), so I want to write one that works the way I work.
I have found some code under the apache license (here) which looks like it does what I want.
Also .Net has a FileWatcherControl, but JNI for using C# looks like a nightmare, creating managed code to that the C# calls that then calls the JNI layer.
I will have a look at the above code and post results if anyway, I have several projects and no time
The JNA project includes some demo code which uses the w32 file system API to report file system changes. You don't have to write any native code, but you may need to tweak the java if the class doesn't do exactly what you want it to already.
"As to MFC well I just remember it as the class library to use to develop Windows application, that wasnt as well put together as OWL and in general to be avoid (Generally i think the writing of Windows apps outside of soemthing like delphi was to be avoided)."
Who told you that - I bet it was someone from Borland (who were selling their own compiler with the OWL library and who were selling Delphi)... :roll: MFC (Microsoft Foundation Classes) is Microsoft's object oriented library to write C++ applications for Windows. Yes, Borland will tell you it is "to be avoided" because they want you to use their tools instead of Microsoft's...
Well the whole OWL thing was down to reading several articals of the time that came out in favour of OWL being somewhat better put together, and more logically organised then MFC. I could be wrong, but I also got the impression at the time OWL existed before MFC came along. Admittedly I was more likley to such articals as I prefered, and still prefer Borland compilors over MS ones (Along with their associated IDE's).
As to avoiding programming windows apps outside of something like delphi, you obivously missed that it was a personaly opinion, and that I said something like delphi, this would include VB, and to a lesser degree C++ Builder and an even lesser degree VC++. I am sure there were other visual tools of the time, but for my money, Delphi was the one to chose, it was object orinetated, and a compiled language, unlike VB. (Which didnt get decent object support until about version 6, was based on basic, and required a runtime library, and we all know what BASIC stands for).
I will get back to JNA just as soon as i get 5minutes to myself. It is probably exactly what I am looking for, I just want to know when a file is added, deleted, or moved. I want to write a file manager application, as I am sick of having to fight with teh current crops I want one that works like I do. Also I am hopeing it will be easier for non techies, but thats for another day.
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