[CLUE-Tech] NoClassDefFoundError

Jeffery Cann fabian at jefferycann.com
Thu Jun 12 22:39:02 MDT 2003


On Thursday 12 June 2003 10:07 pm, Joseph Thomas wrote:
> So do I have to add every directory that I want to store .java files in to
> my classpath?

The java program only reads class files.  So, you only worry about their 
location.  Whether you have to add every directory for your .class files 
depends on the structure of your code.  This is why packages are important.

If you have a program (test) with two packages (hello), (goodbye):

$HOME/test/
$HOME/test/hello/
$HOME/test/goodbye/

You would only need to add $HOME/test to your classpath.  The compiler 
(because of your package declarations in your java code) will find the hello 
and goodbye packages.

>
> I dont have to do that under windows, all I have to do is type 'java
> javafile' and it runs as long as I am in the same directory as that file.

I'm not sure, but I suspect that your $CLASSPATH on windows includes the 
current directory (.).  If you did this on linux, you would get the same 
result and you could then cd to the location where your .class file is to run 
your program (provided it's not in a package).

You can do this by:

$ export CLASSPATH=.

Jeff

>
>
>
>
> ----Original Message Follows----
> From: Jeffery Cann <fabian at jefferycann.com>
> Reply-To: clue-tech at clue.denver.co.us
> To: clue-tech at clue.denver.co.us
> Subject: Re: [CLUE-Tech] NoClassDefFoundError
> Date: Thu, 12 Jun 2003 21:36:27 -0600
>
> On Thursday 12 June 2003 09:30 pm, Joseph Thomas wrote:
>  > I did try that. I am not placing it in any package, I am simply placing
>
> it
>
>  > in a directory called 'test'
>
> Then cd to that directory or put $HOME/test in your $CLASSPATH.
>
> HTH-
>   Jeff

-- 
"Keep yourselves far from every form of exaggerated nationalism, racism and 
intolerance."
-- Pope John Paul II 



More information about the clue-tech mailing list