newbie compile question

Discussion in 'Java' started by Nandan, Nov 4, 2004.

  1. Nandan

    Nandan Guest

    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,
    N
    Nandan, Nov 4, 2004
    #1
    1. Advertising

  2. Nandan

    Fahd Shariff Guest

    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
    http://www.fahdshariff.cjb.net
    "Let the code do the talking..."
    Fahd Shariff, Nov 4, 2004
    #2
    1. Advertising

  3. Andrew Thompson, Nov 4, 2004
    #3
  4. 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 comp.lang.java.help
    in the future, and specific questions regarding tools to
    comp.lang.java.softwaretools

    /Thomas
    Thomas Weidenfeller, Nov 5, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nagaraj
    Replies:
    1
    Views:
    856
    Lionel B
    Mar 1, 2007
  2. timjowers
    Replies:
    7
    Views:
    4,342
    heyjude
    Feb 2, 2011
  3. Replies:
    1
    Views:
    448
    Cowboy \(Gregory A. Beamer\)
    Apr 11, 2008
  4. Carter
    Replies:
    2
    Views:
    502
    Carter
    Mar 4, 2009
  5. fAnSKyer
    Replies:
    2
    Views:
    530
    Alf P. Steinbach
    Jun 7, 2009
Loading...

Share This Page