Code Comments

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











Thread
Author

SOURCEPATH and CLASSPATH
Hi,

My understanding of the CLASSPATH option is as follows:

If javac is building foo, and discovers that it needs bar to accomplish
this,

- if bar.class is found on the CLASSPATH, it uses this
- if bar.java is found on the CLASSPATH, it builds it and uses this new
bar.class
- if bar.java and bar.class are found on the CLASSPATH, and bar.java is
newer than bar.class, it builds bar.java and uses this new bar.class.
If not, it uses the existing bar.class

Assuming this is correct, I don't understand why the SOURCEPATH option
is needed, as there is already a way of specifying the location of
source files (the CLASSPATH). Any ideas?

Also, if you specify an output directory (via the -d option), I presume
this is implicitly used as the first entry on the CLASSPATH?

Please reply to group as this is a "honeypot" e-mail account.
Regards,
Don


Report this thread to moderator Post Follow-up to this message
Old Post
donalmurtagh@yahoo.co.uk
01-10-05 09:00 PM


Re: SOURCEPATH and CLASSPATH
donalmurtagh@yahoo.co.uk wrote:

> Hi,
>
> My understanding of the CLASSPATH option is as follows:
>
> If javac is building foo, and discovers that it needs bar to accomplish
> this,
>
> - if bar.class is found on the CLASSPATH, it uses this
> - if bar.java is found on the CLASSPATH, it builds it and uses this new
> bar.class
> - if bar.java and bar.class are found on the CLASSPATH, and bar.java is
> newer than bar.class, it builds bar.java and uses this new bar.class.
> If not, it uses the existing bar.class

your partially correct, see below for an explanation.

> Assuming this is correct, I don't understand why the SOURCEPATH option
> is needed, as there is already a way of specifying the location of
> source files (the CLASSPATH). Any ideas?

Classpath refers to all the code/libs your source is using,
including libraries written by other software developers.
Your sourcepath refers to the path where the source: the .java files
are found.
Each .java file is complided with a classpath. Therefore if your source
files are dependend of each other (what is often the case) you should includ
e your
source-files in your classpath (because you use them).

I dont know if your using many libraries from other developers (jars).
I do.
Those jars contains of packages with java byte-codes (classes).
I use those classes in my app and therefore i have to add them to my classpa
th.

>
> Also, if you specify an output directory (via the -d option), I presume
> this is implicitly used as the first entry on the CLASSPATH?
>
> Please reply to group as this is a "honeypot" e-mail account.
> Regards,
> Don
>

Report this thread to moderator Post Follow-up to this message
Old Post
Tjerk Wolterink
01-11-05 01:58 AM


Re: SOURCEPATH and CLASSPATH
Thanks for your response, but I still don't really feel I understand
the SOURCEPATH.
I guess my question is this: Do you ever actually *need* to use the
sourcepath or is it just a nice way of separating the location of .java
files from the location of .class files?

For example assume we want to build foo.java, which is located in the
current directory and depends on bar, which is located at
C:\baz\bar.java,
won't both of these work:

> javac -SOURCEPATH C:\baz; foo.java
> javac -CLASSPATH C:\baz; foo.java

Best Wishes,
Don


Report this thread to moderator Post Follow-up to this message
Old Post
donalmurtagh@yahoo.co.uk
01-11-05 01:57 PM


Re: SOURCEPATH and CLASSPATH
On 11 Jan 2005 01:27:31 -0800, donalmurtagh@yahoo.co.uk wrote:

> I guess my question is this: Do you ever actually *need* to use the
> sourcepath

No.  You can leave out the -sourcepath option and compile the classes
to the same place as the source, if you wish.

>..or is it just a nice way of separating the location of .java
> files from the location of .class files?

At least that(, perhaps more).

On a different matter.

Please note that the 'alt.*' hierarchy is not the best place
to look for technical groups.  Peruse further details on the
(excellent) comp.lang.java.* groups here.
<http://www.physci.org/codes/javafaq.jsp#groups>

Note - Follow-ups set to comp.lang.java.help only.

--
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Thompson
01-11-05 01:57 PM


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 04:22 AM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.