This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Compilation of the java files in folders  RSS feed

 
Monish Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
I have a problem regarding the compilation...
I want to compile all the java files in the folders at a time. Now every folder has folders in them and there are different java files scattered in the folders. I am trying to compile all the java files from the parent folders and i am not able to do so through command prompt,,,Urgently need the command to do so,,,If any path settings required the please send that,,,
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a UNIX-like system, it's trivial -- you can use the "find" command and backquotes:

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

If you're stuck on Windows, then I can't help you.
 
Sharath Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
compilation of all the files in a directory can be done as follows


Suppose you have a directory "abc" which contains say two java files d1.java,d2.java and a directory called "a" which in turn contains d3.java.

first move to the home dir i.e move to dir "abc".create a text file say ex.txt
now inside it write the names of all the files in the directory and subdirectories
d1.java
d2.java
a\d3.java

now go to the commaand prompt and type javac @ex.txt

comments are invited and correct me if i am wrong
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharath Kumar:

comments are invited and correct me if i am wrong


You're not wrong, but I thought the whole point of the question was to avoid manually tracking all the filenames or setting up a build file; this is for a "quick and dirty" application. A much better solution is to use Ant and create a build.xml file to build the project automatically; Ant includes tags that let you specify "all the source files in this directory tree" as a target.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:


You're not wrong, but I thought the whole point of the question was to avoid manually tracking all the filenames or setting up a build file; this is for a "quick and dirty" application. A much better solution is to use Ant and create a build.xml file to build the project automatically; Ant includes tags that let you specify "all the source files in this directory tree" as a target.


Ernest,

I think the Sharath, is somehow right..!!

Well I think it is one time exercise, later onwards now you never need to do it again if you are not adding any other file in it.

Remember,
Not everybody has Ant installed on his machine. In that way Sharath Kumar
has better solution.

Anyways Sharath, thanks for this solution.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!