Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messagedonalmurtagh@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 >
Post Follow-up to this messageThanks 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
Post Follow-up to this messageOn 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.