File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes compiling all files in all subdirecoty? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "compiling all files in all subdirecoty?" Watch "compiling all files in all subdirecoty?" New topic

compiling all files in all subdirecoty?

Sreedhar mar
Ranch Hand

Joined: Sep 15, 2003
Posts: 34

i want to compile all the files which are in different directorys like this


i want to compile all files in a,b,c directorys from c:\java at time (in a single command)

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24166

javac `find . -name '*.java'`

What? You're using Windows? Oh, sorry to hear that.

Most people use Ant these days for building Java applications. It's fairly easy to use and it solves this particular problem easily. Once you set up an Ant build file for your project, it will save you a lot of typing.

[Jess in Action][AskingGoodQuestions]
Jean-Francois Briere
Ranch Hand

Joined: Mar 03, 2004
Posts: 101
Yes ANT is the best build tool available for JAVA. I use it all the time!
I'm on Windows XP Pro and the cmd shell is, well, not allways useful (to say the least).
But if you want to do things like javac `find . -name '*.java'`, you can also install Cygwin and have fun!
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

and unixutils are available without linux-emulator for windows too.

But if I understand correctly, your dirs are:

If they belong to the same project, a 'javac b\' should work, if your package-declarations are in order.

I read something about a switch to compile all files, found listed in a file.

Yes - I found it again:

go to your sysarchitecture, and find:
javac @argfile
which means in the example above:

Since javac without arguments shows some options, it's surprising, that there are additional options, not shown.

Since sun normally is very calculable, this is super-surprising.

[ September 21, 2004: Message edited by: Stefan Wagner ]
[ September 21, 2004: Message edited by: Stefan Wagner ]
I agree. Here's the link:
subject: compiling all files in all subdirecoty?
Similar Threads
batch file
Compilation question
Creating directory structure dynamically
code redundancy
how to create WAR files