I look at a lot of small Java programs. It would be convenient if I could set up a directory (or directory structure) on my Mac where any time I add a .java file, javac automatically runs and attempts to compile that file. I've briefly looked into Automator actions, but found nothing that fits the bill. Then I got to thinking: on my PC, I would use the .Net FileSystemWatcher class and write the code myself. But before I try that on my Mac with Mono, I want to ask the community for other ideas. Any advice is appreciated. Thanks.
views:
59answers:
2If you have all the .java files available at the start, you could write a shell script to compile them all in one run -- in different directories if you need to.
If you explained why you would want this, maybe I/we could be more helpful.
In JDK6 you can programmatically compile, so you could write your own program to do this, which may be slightly better than doing it in mono.
So you would just have a program that is always running, it looks for either any new files or a file that has been changed since the last check and then just compiles them, and you may want it to pass information to a dashboard window when there are errors, and perhaps some status info so you know it is working.
http://binkley.blogspot.com/2005/09/programmatically-compiling-java-in-jdk.html