Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > compile whole project help

Reply
Thread Tools

compile whole project help

 
 
f
Guest
Posts: n/a
 
      12-05-2003
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
 
Reply With Quote
 
 
 
 
Anthony Borla
Guest
Posts: n/a
 
      12-05-2003
"f" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
>
> 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


 
Reply With Quote
 
 
 
 
Mladen Adamovic
Guest
Posts: n/a
 
      12-05-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
f
Guest
Posts: n/a
 
      12-05-2003
does that compile -subpackage1 also?

"Anthony Borla" <(E-Mail Removed)> wrote in message news:<e2Vzb.40253$(E-Mail Removed)>...
> "f" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> >
> > 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

 
Reply With Quote
 
 
 
Reply

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
How can i compile a whole Webproject on a production server? Mayer, Stefan ASP .Net 1 02-28-2008 11:13 AM
compile errors when converting web site project to web application project John Dalberg ASP .Net 1 03-28-2007 12:54 AM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
*WITHOUT* using: ValidateRequest="False" for the whole page (or my whole site).... \A_Michigan_User\ ASP .Net 2 08-21-2006 02:13 PM
Declaring an Enum that the whole project can use? danthman ASP .Net 4 12-17-2005 01:47 AM



Advertisments