Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

How to start compiling a big package directory tree ?
I downloaded a java source of a tool which is spread over multiple (40-50) *
.java files
which are located in different sub directories according to their package na
me.

Unfortunately no further instructions (e.g. Ant script) are available.
However the source should be compileable without errors.

How do I start ?

Which class should I compile first ?

For example I found a "main()" method in java file SomeGUI.java

When I switch now to the base directory of package:

D:\java\base\

and type at the command prompt:

javac org\somepack1\subpack2\SomeGUI.java

then the compiler tell me that he cannot find a file/package "org.somepack.a
ddclass"
But the java file org\soempack\addclass.java EXISTS !

Why does the compiler not find this class/source ?

Can I somehow tell the compiler (from the command line !):

"here is the source directory tree. Search for all you need and compile all
necessary classes in the sequence you need".

Tom


Report this thread to moderator Post Follow-up to this message
Old Post
Tom Parson
08-16-07 01:11 PM


Re: How to start compiling a big package directory tree ?
Tom Parson wrote:
> Can I somehow tell the compiler (from the command line !):
>
> "here is the source directory tree. Search for all you need and compile al
l
> necessary classes in the sequence you need".

I don't think javac can recursively compile packages.
But creating a simple Ant build.xml should be that hard:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="compile" name="standard">
<target name="compile">
<javac destdir="." srcdir="." />
</target>
</project>

If you drop that into D:\java\base\ and type ant it will automatically
compile all sources. You might want to adjust destdir to create the
class files into a different directory.

Thomas

Report this thread to moderator Post Follow-up to this message
Old Post
Thomas Kellerer
08-16-07 01:11 PM


Re: How to start compiling a big package directory tree ?
Tom Parson wrote:
> I downloaded a java source of a tool which is spread over multiple (40-50)
 *.java files
> which are located in different sub directories according to their package 
name.
>
> Unfortunately no further instructions (e.g. Ant script) are available.
> However the source should be compileable without errors.
>
> How do I start ?
>
> Which class should I compile first ?
>
> For example I found a "main()" method in java file SomeGUI.java
>
> When I switch now to the base directory of package:
>
> D:\java\base\
>
> and type at the command prompt:
>
> javac org\somepack1\subpack2\SomeGUI.java
>
> then the compiler tell me that he cannot find a file/package "org.somepack
.addclass"
> But the java file org\soempack\addclass.java EXISTS !
>
> Why does the compiler not find this class/source ?
>
> Can I somehow tell the compiler (from the command line !):
>
> "here is the source directory tree. Search for all you need and compile al
l
> necessary classes in the sequence you need".

Well, on *nix,
find . -name "*.java"
will find the files
so
javac `find . -name "*.java"`

will compile all the files simultaneously, or at least
compile them all "in the same context", which I think
will solve some of the dependancy issues.

All this is from guessing - I use Ant!!

BugBear

Report this thread to moderator Post Follow-up to this message
Old Post
bugbear
08-16-07 01:11 PM


Re: How to start compiling a big package directory tree ?
bugbear wrote:
> Tom Parson wrote: 
>
> Well, on *nix,
>    find . -name "*.java"
> will find the files
> so
>    javac `find . -name "*.java"`
>
> will compile all the files simultaneously, or at least
> compile them all "in the same context", which I think
> will solve some of the dependancy issues.
>
> All this is from guessing - I use Ant!!

The find hack will also work on Windows with Cygwin.

--
Lew

Report this thread to moderator Post Follow-up to this message
Old Post
Lew
08-16-07 01:11 PM


Re: How to start compiling a big package directory tree ?
On 16 Aug 2007 10:20:53 GMT, tom.parson@gm.com (Tom Parson) wrote,
quoted or indirectly quoted someone who said :

>How do I start ?
see http://mindprod.com/jgloss/ant.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Report this thread to moderator Post Follow-up to this message
Old Post
Roedy Green
08-17-07 12:19 AM


Re: How to start compiling a big package directory tree ?
On Aug 16, 3:20 am, tom.par...@gm.com (Tom Parson) wrote:
> I downloaded a java source of a tool which is spread over multiple (40-50)
 *.java files
> which are located in different sub directories according to their package 
name.
>
> Unfortunately no further instructions (e.g. Ant script) are available.
> However the source should be compileable without errors.
>
> How do I start ?
>
> Which class should I compile first ?
>
> For example I found a "main()" method in java file SomeGUI.java
>
> When I switch now to the base directory of package:
>
> D:\java\base\
>
> and type at the command prompt:
>
> javac org\somepack1\subpack2\SomeGUI.java
>
> then the compiler tell me that he cannot find a file/package "org.somepack
.addclass"
> But the java file org\soempack\addclass.java EXISTS !
>
> Why does the compiler not find this class/source ?
>
> Can I somehow tell the compiler (from the command line !):
>
> "here is the source directory tree. Search for all you need and compile al
l
> necessary classes in the sequence you need".
>
> Tom

I think the best option would be to write a simple build.xml with a
<javac> task to do the job.

If non-command line, drop the com tree into a new java project in
Eclipse or use the import feature.

-cheers,
Manish

-cheers,
Manish



Report this thread to moderator Post Follow-up to this message
Old Post
Manish Pandit
08-17-07 12:19 AM


Re: How to start compiling a big package directory tree ?
Hi Tom,
Tom Parson wrote:
> I downloaded a java source of a tool which is spread over multiple (40-50)
> *.java files which are located in different sub directories according to
> their package name.
>
> Unfortunately no further instructions (e.g. Ant script) are available.
> However the source should be compileable without errors.

I would suggest you'd just write a small ant file yourself which will do the
compiling. Still better than messing around with javac and compiling every
single class yourself.

Best regards,
Jan

--
 ________________________________________
_________________________________
insOMnia - We never sleep...
http://www.insOMnia-hq.de

Report this thread to moderator Post Follow-up to this message
Old Post
Jan Thomä
08-22-07 12:12 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:48 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.