Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting Path and Classpath?

 
Anup Agrawal
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings!
I am unable to run javac from the command prompt (except from c:\j2sdk1.4\bin). I tried setting path and classpath as follows but it isnt working.
set PATH = c:\j2sdk1.4\bin;%PATH%
set CLASSPATH = .;c:\j2sdk1.4\bin;%CLASSPATH%
I tried various combinations but it is not working. By default every where java command is working. Havent installed any Java IDE.
Help me in resolving this?
Thanks!
 
Arulkumar Gopalan
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Please set the path as given below.
set PATH=%PATH%;c:\j2sdk1.4\bin;
set CLASSPATH =%CLASSPATH%;.;
If you do this in your command prompt that is available only in that session. So, please do update your system environment variables.
 
Anup Agrawal
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried, but it is not working.
 
Anup Agrawal
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it through the help of my friend.
I modified the path variable in System Enviorment Variables. It started recognizing javac.
But still I have doubt why it was not doing when I was changing it on the command prompt. (In command prompt for that particular session only)
when I set the path variable and then tried set command. It showed me the changes I made it in that particular session, still it was not recognizing javac command. Where as after changing Enviorment variables it worked successfully. Can somebody explain this?
 
Doug Dunn
Author
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep many different versions of Java on an XP machine and use the System Properties control panel (See Environment Variables button on the Advanced tab) to set the path. I tried the set command after reading your post, however, and noticed that it does not work if spaces are used on either side of = (e.g. "set Path = %path%;..." versus "set Path=%path%;...", so try it without the spaces. Also, you can use the path command by itself to display the path and see if your set command worked.
A previous responder insisted that you use the %path% at the start of the set command, but that depends on what you are trying to do. If I were to do that, for example, it would always use the version I have preset in my path environment variable. I have to put %path% last in order to switch between different versions.
 
Anup Agrawal
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr. Doug.
Amazing!
I tried without spaces and it worked. Really amazing for me.
But why is it like this? Nowdays I think almost all software take care of spaces automattically. In previous versions of windows it used to accept spaces in between (set Path = c:\j2sdk1.4\bin). Is there any performance reason or ignorance of the programmers for such a idea(set command can work only without spaces).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic