The CLASSPATH
environment variable is only used by the java.exe
command and even then only when used without any of the -cp
, -classpath
, -jar
arguments. It is ignored by IDEs like Eclipse, Netbeans and IDEA.
That environment variable is in real world also considered a poor practice since it breaks portability. I.e. program X will run successfully while program Y won't run without altering the CLASSPATH
. It's only "useful" for Sun Oracle to prevent that starters get tired of typing the same classpath again and again in the -cp
or -classpath
arguments when following Java tutorials. In real world, batch/shell files are preferred where just the entire command with -cp
/-classpath
argument is specified.
In your case you're using an IDE. The classpath is there called the "Build Path". In plain Java projects, it represents both the compiletime and runtime classpath. You can configure it in the project's properties. You can add a complete folder, you can add individual/external JAR files, you can link projects, etcetera. Make use of it. Forget about using the CLASSPATH
environment variable. It was a mistake by Sun Oracle. They thought to convince starters, but it ended up to be only more confusing to starters as they incorrectly interpret that environment variable as the classpath.
See also:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…