1

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. E.X.

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?

3 Answers 3

2

The % notation is used to access environment variables in windows. E.g. 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 e.g.

echo %classpath%

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

Sign up to request clarification or add additional context in comments.

2 Comments

You can also use the command set classpath without the =newvalue to see the current value, and you can use the command set on its own to see the current value of all environment variables.
This is ofcourse for Windows. On Linux and Mac OS X it's $CLASSPATH instead of %CLASSPATH%.
2

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.)

Comments

1

%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.

3 Comments

ok, thanks for answering guys... one more thing ... in the current context what will %classpath% point too(I mean what value does it store) give me an example please
What do you mean by current context? The current classpath may have been set via the Environment Variables button in the System Control Panel or by other commands that you've run from the command line.
sorry at 1st your answer loaded only partially... when I reloaded the webpage then only the full answer came.... that's why i asked for that...anyways I understood the thing.. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.