• Post Reply Bookmark Topic Watch Topic
  • New Topic

batch file  RSS feed

 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to write a batch file which will compile all the java files under directory a and its subdirectory ?
For example!.
I have a directoy structure like(say)
a
a\b
a\d\e
a\c
a\e
a\x\

each of these directories and sub-directories contains 0..many java files
now if I want to compile them, I usually do
javac a\d\e\*.java a\b\*.java ...etc.,

Is there any other easy way!.. ?
Don't know where to post this question!. So i request moderator to move it to appropriate forum if needed.
Rgds
Balaji
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you really want is Ant (http://jakarta.apache.org/ant). "Batch files" usually means a command script for Windows, and the Windows batch scripting language is about as brain-dead as they come. I think it's possible to do what you want in a batch file, but it would be very ugly.
Ant is a tool written in Java desigend to understand the nuances of how Java apps get built. It's also OS-independent. Windows batch files can't run under Linux any better than Linux shell scripts run in Windows, but an Ant project will work the same in both places*.
Although it may seem a bit much at first, the actual download and install of the basic Ant system is quite simple. And the core Ant system is all you'll need for many projects. The controlling file for a Java project is the build.xml file, which is an XML-format file with the instructions on how to build your application. There are een special commands to assist in creating WAR and EAR files.
---
*Actual mileage may vary depending on driver and road conditions.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66151
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second the motion for ant! It saves an unbelievable amount of time during the development and release cycles.
Any up-front time costs in obtaining, learning and setting up ant will pay for itself for even small projects.
Not to mention the savings on the wear and tear of your psyche...
hth,
bear
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for taking time to reply.I agree, was bit lazy to learn that tool even though when its come packaged.
Yes!.. I'm reading the Ant user guide now
Thanks again.
Regards
Balaji
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started using this tool(ant).
Wrote my own build.xml file..
My God!.. its so simple and very fast.
Thanks guys
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!