Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > newbie compile question

Thread Tools

newbie compile question

Posts: n/a
I have a set of .java files in a directory hierarchy (organized according to
their respective packages) under src.

How can I use the java command line compiler to compile all the relevant
files? I know of the

javac -d bin *.java
trick that populates a bin directory in a package-appropriate way.
after that I can simply run jar cf bin with some extra options.

Is there some way to make the java compiler recursively compile all
the .java files belonging to the src dir's package hierarchy?

Thanks a lot,
Reply With Quote
Fahd Shariff
Posts: n/a
You can use something ugly like: javac */*/.../*.java

Or use command substitution from the root source directory: javac
`find . -name *.java`

But my favourite is ant. If you dont know it, learn it. Its a great
skill to have.

Fahd Shariff
"Let the code do the talking..."
Reply With Quote
Andrew Thompson
Posts: n/a
On Thu, 04 Nov 2004 11:01:07 -0500, Nandan wrote:

> Sub: newbie ... question dealt with on a group described here..

Andrew Thompson Web & IT Help Open-source software suite Science & Technology Images that escape the mundane
Reply With Quote
Thomas Weidenfeller
Posts: n/a
Nandan wrote:
> Is there some way to make the java compiler recursively compile all
> the .java files belonging to the src dir's package hierarchy?

Usually people use what is called a "build system" for such tasks,
because all the typing gets boring after some time.

Either they use the build-in build system ("project management") of some
IDE, or some external build tool. Common external build tools are make
(the generic make versions have some problems with the way javac works),
or ant (specifically made for Java, but with an absolutely brain-dead,
XML-based file format).

BTW: You might want to post beginner's questions to
in the future, and specific questions regarding tools to

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
compile directive for conditional compile for Java 1.4 versus Java 5 timjowers Java 7 02-02-2011 12:08 AM
How to compile the following source code in VC6// I have error inVC++6 but compile ok in GCC fAnSKyer C++ 2 06-07-2009 07:57 AM
computation at compile time i.e. compile time functions usingtemplates Carter C++ 2 03-04-2009 06:43 PM
Compile versus not compile (VS 2005)?? ASP .Net 1 04-11-2008 08:24 PM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM