compile whole project help

Discussion in 'Java' started by f, Dec 5, 2003.

  1. f

    f Guest

    I have the following java code at file system:

    -MyProject
    -class
    -src
    -com
    -company
    -project
    file1.java
    file2.java
    -subpackage1
    file11.java
    -subpackage2
    file21.java
    file22.java

    I am compiling with command line javac. Is there a command to compile
    all the java file together and put the result at my class directory?

    Thanks,

    ff
     
    f, Dec 5, 2003
    #1
    1. Advertising

  2. "f" <> wrote in message
    news:...
    >
    > I have the following java code at file system:
    >
    > -MyProject
    > -class
    > -src
    > -com
    > -company
    > -project
    > file1.java
    > file2.java
    > -subpackage1
    > file11.java
    > -subpackage2
    > file21.java
    > file22.java
    >
    > I am compiling with command line javac. Is there a
    > command to compile all the java file together and put
    > the result at my class directory?
    >


    Assuming that 'MyProject' is in the top-level directory, and the requisite
    'package' and 'import' statements are correctly in place, then the following
    should do as you require:

    javac -d MyProject/class
    MyProject/src/com/company/project/*.java

    Note: the above should be a single line

    Assuming 'file1.class' as the application launch file, then you can execute
    this as:

    cd MyProject/class
    java MyProject.src.com.company.project.file1

    I'm not sure, however, that you really want such a - IMO - convoluted
    package structure. One reason I say this is because you will find your
    'class' directory containing the entire project directoy hierarchy ! This
    occurs, naturally enough, in order to match the package structure. May I
    suggest two things. Firstly, change to the following directory structure
    [alter your package statements accordingly]:

    -com
    -company
    -MyProject
    file1.java
    file2.java
    -subpackage1
    file11.java
    -subpackage2
    file21.java
    file22.java

    Secondly, have the '.class' files created on another drive [if you are on a
    Windows system -another mounted directory for *NIX people] mimicing the same
    structure. For example, on a Windows system, assuming your source is on
    drive X:, then target your '.class' files for drive Y: - this is shown:

    X:
    cd \
    javac -d Y:\ com/company/MyProject/*.java

    The '.class' files now exist in the same directoy structure on drive Y:, so
    to execute:

    Y:
    cd \
    java com.company.MyProject.file1

    Of course drive Y: could merely be a SUBSTed drive [i.e. an alias for a
    directory located locally, or remotely located - even located on drive X:
    !]. I believe it is a very clean, simple way of separating source and
    '.class' files which can be accomplished from the command-line without batch
    files / scripts.

    I hope this helps.

    Anthony Borla
     
    Anthony Borla, Dec 5, 2003
    #2
    1. Advertising

  3. I think you should use some make tool.
    You might want to use GNU make,
    but I strongly recommend you ant, platform independent
    Java make tool, look at the:
    http://ant.apache.org

    "f" <> wrote in message
    news:...
    > I have the following java code at file system:
    >
    > -MyProject
    > -class
    > -src
    > -com
    > -company
    > -project
    > file1.java
    > file2.java
    > -subpackage1
    > file11.java
    > -subpackage2
    > file21.java
    > file22.java
    >
    > I am compiling with command line javac. Is there a command to compile
    > all the java file together and put the result at my class directory?
    >
    > Thanks,
    >
    > ff
     
    Mladen Adamovic, Dec 5, 2003
    #3
  4. f

    f Guest

    does that compile -subpackage1 also?

    "Anthony Borla" <> wrote in message news:<e2Vzb.40253$>...
    > "f" <> wrote in message
    > news:...
    > >
    > > I have the following java code at file system:
    > >
    > > -MyProject
    > > -class
    > > -src
    > > -com
    > > -company
    > > -project
    > > file1.java
    > > file2.java
    > > -subpackage1
    > > file11.java
    > > -subpackage2
    > > file21.java
    > > file22.java
    > >
    > > I am compiling with command line javac. Is there a
    > > command to compile all the java file together and put
    > > the result at my class directory?
    > >

    >
    > Assuming that 'MyProject' is in the top-level directory, and the requisite
    > 'package' and 'import' statements are correctly in place, then the following
    > should do as you require:
    >
    > javac -d MyProject/class
    > MyProject/src/com/company/project/*.java
    >
    > Note: the above should be a single line
    >
    > Assuming 'file1.class' as the application launch file, then you can execute
    > this as:
    >
    > cd MyProject/class
    > java MyProject.src.com.company.project.file1
    >
    > I'm not sure, however, that you really want such a - IMO - convoluted
    > package structure. One reason I say this is because you will find your
    > 'class' directory containing the entire project directoy hierarchy ! This
    > occurs, naturally enough, in order to match the package structure. May I
    > suggest two things. Firstly, change to the following directory structure
    > [alter your package statements accordingly]:
    >
    > -com
    > -company
    > -MyProject
    > file1.java
    > file2.java
    > -subpackage1
    > file11.java
    > -subpackage2
    > file21.java
    > file22.java
    >
    > Secondly, have the '.class' files created on another drive [if you are on a
    > Windows system -another mounted directory for *NIX people] mimicing the same
    > structure. For example, on a Windows system, assuming your source is on
    > drive X:, then target your '.class' files for drive Y: - this is shown:
    >
    > X:
    > cd \
    > javac -d Y:\ com/company/MyProject/*.java
    >
    > The '.class' files now exist in the same directoy structure on drive Y:, so
    > to execute:
    >
    > Y:
    > cd \
    > java com.company.MyProject.file1
    >
    > Of course drive Y: could merely be a SUBSTed drive [i.e. an alias for a
    > directory located locally, or remotely located - even located on drive X:
    > !]. I believe it is a very clean, simple way of separating source and
    > '.class' files which can be accomplished from the command-line without batch
    > files / scripts.
    >
    > I hope this helps.
    >
    > Anthony Borla
     
    f, Dec 5, 2003
    #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. danthman
    Replies:
    4
    Views:
    357
    =?Utf-8?B?RGF2aWQgSmVzc2Vl?=
    Dec 17, 2005
  2. \A_Michigan_User\
    Replies:
    2
    Views:
    928
    \A_Michigan_User\
    Aug 21, 2006
  3. Nagaraj
    Replies:
    1
    Views:
    901
    Lionel B
    Mar 1, 2007
  4. John Dalberg
    Replies:
    1
    Views:
    528
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 28, 2007
  5. Mayer, Stefan
    Replies:
    1
    Views:
    338
    Juan T. Llibre
    Feb 28, 2008
Loading...

Share This Page