Print

Print


To add a bit of experience gained from 13 years of Java programming: I
strongly recommend against setting CLASSPATH in the shell. Instead,
use either the -cp switch to java, as in

java -cp lucene-core...jar:lucene-demo-.jar ....

or use the "env" command in Unix, as in

env CLASSPATH=/home/eric/lucene/lucene-core-2.3.0.jar:/home/eric/lucence/lucene-demos-2.3.0.jar
java ....

These options achieve the same effect, but unlike "export", they will
not change the CLASSPATH environment variable for the remainder of
your shell session.  For instance, this command:

export CLASSPATH=/home/eric/lucene/lucene-core-2.3.0.jar:/home/eric/lucence/lucene-demos-2.3.0.jar

will make it impossible to execute javac or java for .class files in
the current directory (because you've excluded . from the classpath,
which by default is included.)

Note, however, that this rule does not apply to shell scripts: inside
shell scripts, it's okay to export CLASSPATH because such settings
will be valid only for the shell executing the script; in Unix,
changes to environment variable will not reflect back to the shell
from the shell script was started.

 - Godmar

> >
> > You use a plain directory as a CLASSPATH component only if you intend
> > to use .class files that has not been packaged up in a JAR.
>
>
>
> Thank you for the prompt replies. Yes, my CLASSPATH needed to be more
> specific; it needed to specify the .jar files explicitly. I can now
> run the demo. (Arg! Classpaths!)
>
> --
> ELM
>