简体   繁体   中英

What does %classpath% means while setting the classpath for java

I want to know about the symbol % that is written while setting the classpath or while setting the path for the jdk in command prompt in windows. EX

set classpath=%classpath% ;.;

or

set path=%path% ;.;C:\\Program Files\\Java\\jdk1.7.0_01

I want to know about %path% and %classpath%

What do they mean and what is the special % symbol about?

Those are environment variables. And environment variables are what you're setting. Basically, they're saying "Take the old value of this environment variable and append the following literal text to it". The % just clues in the command interpreter to do the variable substitution vs treating "path" or "classpath" as literal text.

(Similar but different notation is used in shell interpreters on Unix/Linux.)

The % notation is used to access environment variables in windows. Eg in the line

set classpath=%classpath%;.

the part %classpath% is replaced with the current content of this variable and then appended by ;. and then rewritten to the same variable.

On command line promt you can write eg

echo %classpath%

which will show you the content directly (as with set classpath ).

%classpath% is the current value of the classpath so

set classpath=%classpath% ;.;

adds the current directory onto the end of whatever the current value of the classpath is.

Likewise, set path=%path% ;.;C:\\Program Files\\Java\\jdk1.7.0_01 adds the current directory and the JDK directory onto the end of the current path.

Note: this is not anything specific to path and classpath. %variablename% is the syntax for the value of the environment variable variablename .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM