🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8520

Re: CLASSPATH

#8520
From: Jon Skeet
Date: Sun, 18 Mar 2001 07:52
52 lines
3400 bytes
Harry J. Kobetitsch <kobet@ix.netcom.com> wrote:
> I am running Windows 2000 and I am using the Java 2 SDK and
> Forte 2.0. I also used Command Prompt and using javac from the
> command line and I get the same type of problem.
> 
> I have set CLASSPATH to C:\Harry\Java
> I have the following two classes that I am trying to build
> Other.class and OtherTest.class

<snip>

> Do I have the CLASSPATH set up correctly?

Well, you don't have "." in your classpath, which is sometimes a 
problem. 

However, it sounds like you don't have your source appropriately located 
according to package, which could also be the problem. I don't know the 
exact requirements of how much of the following is actually necessary, 
but I think most of it's good practice anyway:

o Don't bother setting a classpath unless you really need one. Java2 is 
much better than Java 1 at getting things right, and I find I only need 
a classpath in a few circumstances. Often I find that people with one 
set up have more hassles than those without.

o Always organise your source according to package, so if your "root" 
source directory is c:\Harry\Java, you should have
c:\Harry\Java\OtherTest.java (it's not in a package)
c:\Harry\Java\com\kobet\samples\Other.java

o Always compile from your root directory, with a -d option (I usually 
use -d ., but you could use -d classes if you wanted to keep classes and 
source separate)

o When in doubt, compile everything in one command line. This becomes 
time consuming when you have vast numbers of classes, but if a full 
compile takes about 5 seconds (which it does with a few hundred classes 
on the project I'm working on, for instance) then a problem caused by 
failing to recompile something that needed recompiling which takes 5 
minutes to figure out means I could have done 60 full recompiles in that 
time. The @files.txt syntax for javac helps here. You can put the 
following in a batch file:
dir /s /b *.java > files.txt
javac -d . @files.txt


Follow the above and you shouldn't have any problems.

-- 
Jon Skeet - skeet@pobox.com
http://www.pobox.com/~skeet
Technical Details
Message-ID: <MPG.151e79aff72eef9e989e7c@10.1.1.51>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!freenix!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!join.news.pipex.net!pipex!grot.news.pipex.net!pipex!drip.news.pipex.net!pipex!drop.news.uk.uu.net!eyre.news.uk.uu.net!tube.news.pipex.net!pipex!news.peramon.com!10.1.3.8
References: <991cm4$i8t$1@slb7.atl.mindspring.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113ae9,21ace6450f42c0b
X-Google-Attributes: gid113ae9,public
X-Google-Thread: 10a146,21ace6450f42c0b
X-Google-Attributes: gid10a146,public
X-Google-Thread: f74b3,21ace6450f42c0b
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-17 23:50:05 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!freenix!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!join.news.pipex.net!pipex!grot.news.pipex.net!pipex!drip.news.pipex.net!pipex!drop.news.uk.uu.net!eyre.news.uk.uu.net!tube.news.pipex.net!pipex!news.peramon.com!10.1.3.8
From: Jon Skeet <skeet@pobox.com>
Newsgroups: borland.public.jbuilder.java.language,comp.lang.java.help,comp.lang.java.programmer
Subject: Re: CLASSPATH
Date: Sun, 18 Mar 2001 07:52:52 -0000
Organization: Peramon Technology Ltd.
Lines: 52
Message-ID: <MPG.151e79aff72eef9e989e7c@10.1.1.51>
References: <991cm4$i8t$1@slb7.atl.mindspring.net>
NNTP-Posting-Host: fw1.peramon.com
X-Trace: soap.pipex.net 984901722 13546 193.132.195.113 (18 Mar 2001 07:48:42 GMT)
X-Complaints-To: abuse@uk.uu.net
NNTP-Posting-Date: 18 Mar 2001 07:48:42 GMT
X-Newsreader: MicroPlanet Gravity v2.30