Compiling a source tree.

D

Dave Rudolf

Hi all,

So I have a directory tree of source code that I wish to compile, like so:

d:\852\src\texdist\gui\LatticeHistogramData.java
d:\852\src\texdist\gui\Dialogs.java
d:\852\src\texdist\gui\PnlHistogram.java
d:\852\src\texdist\gui\PnlHistogramCell.java
d:\852\src\texdist\gui\PnlTextEntry.java
d:\852\src\texdist\gui\PnlPropertyCreator.java
d:\852\src\texdist\gui\PnlRightSplitPane.java
d:\852\src\texdist\gui\test\PnlPropertyCreatorTest.java
d:\852\src\texdist\gui\test\PnlHistogramTest.java
d:\852\src\texdist\gui\lattice\LblLattice.java
d:\852\src\texdist\gui\lattice\LblBitArray2D.java
d:\852\src\texdist\gui\lattice\PnlSegments.java
d:\852\src\texdist\texture\ReactionDiffusionTexturer.java
d:\852\src\texdist\texture\diffusion\DirectionalDiffusionFunction.java
d:\852\src\texdist\texture\diffusion\UniformDiffusionFunction.java
d:\852\src\texdist\texture\diffusion\AbstractDiffusionFunction.java
d:\852\src\texdist\texture\distribution\RegularDistribution.java
d:\852\src\texdist\texture\distribution\StripedDistribution.java
d:\852\src\texdist\texture\distribution\AbstractDistribution.java
..... and so on.

I want to write a script that will build the entire tree. Of course, I could
do a javac and list every existing .java file, but then I have to maintain
the list as files are added or removed. On UNIX, I could go to the src
directory and do something like:

javac `find . -name *.java`

Alas, the code is being compiled on a Windows box.

Is there some obscure option to javac that will make it recurse a directory
tree? Other programs like ANT and JBuilder can do this, though they may be
generating the list of files internally.

Dave.
 
B

Brad BARCLAY

Dave said:
Is there some obscure option to javac that will make it recurse a directory
tree? Other programs like ANT and JBuilder can do this, though they may be
generating the list of files internally.

JavaC can do this automatically if all of the classes and interfaces
are reachable from a single class. That is, if the classes form a
single project, and there aren't any classes or interfaces which aren't
referenced by other classes/interfaces (except via reflection), JavaC
will attempt to resolve and compile all of the source files.

Do this by pointing your CLASSPATH to the directory containing the root
of your packages, and then running JAVAC against one class through which
all the rest are reachable (usually the class you'd expect a user to run).

If the classes form a library of functionality, then you're going to
have to run JAVAC against each directory with "*.java" as the filename.
And for that either you're going to have to create a batch file that
hard-codes each package directory that contains sources, or you're going
to have to write a script to retreive the list.

If you're going to so much trouble in the first place, however, you
should probably just setup Ant. This is what it's designed to do, and
once setup makes maintaining such projects a whole lot easier.

Brad BARCLAY
 
D

David Zimmerman

Dave said:
Hi all,

So I have a directory tree of source code that I wish to compile, like so:

d:\852\src\texdist\gui\LatticeHistogramData.java
d:\852\src\texdist\gui\Dialogs.java ....
.... and so on.

I want to write a script that will build the entire tree. Of course, I could
do a javac and list every existing .java file, but then I have to maintain
the list as files are added or removed. On UNIX, I could go to the src
directory and do something like:

javac `find . -name *.java`

Alas, the code is being compiled on a Windows box.

Is there some obscure option to javac that will make it recurse a directory
tree? Other programs like ANT and JBuilder can do this, though they may be
generating the list of files internally.

Dave.

I use CYGWIN on windows and it gives me a pretty good UNIX feel. I use
find and xargs all the time.

Another idea of you don't do any dynamic class laoding, is to remove all
the class files and compile the class with the main in it. The compiler
will find all the others as it discovers the references in your code.

'ant' is a much better idea in the long run. It does indeed build a
list internally. Its got a bit of a learning curve but it's worth it.
 
H

hiwa

If you insist, for whatever reason, on using Windows as a developing
platform, at least you should import UNIX tools for Windows. I believe
Microsoft is one of those vendors, but MKS might be better.
 
T

Tor Iver Wilhelmsen

Dave Rudolf said:
javac `find . -name *.java`

Alas, the code is being compiled on a Windows box.

If your Windows is of the NT family, look at all the nice options to
DIR or FOR.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,351
Latest member
RoxiePulli

Latest Threads

Top