This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Setting Path and Classpath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Setting Path and Classpath?" Watch "Setting Path and Classpath?" New topic
Author

Setting Path and Classpath?

Anup Agrawal
Greenhorn

Joined: Jun 09, 2001
Posts: 19
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

Joined: Oct 13, 2003
Posts: 104
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.


Anbudan & Mahalo,<br />Arul<br /> <br />-Not a sun certified Java professional :-)
Anup Agrawal
Greenhorn

Joined: Jun 09, 2001
Posts: 19
I tried, but it is not working.
Anup Agrawal
Greenhorn

Joined: Jun 09, 2001
Posts: 19
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

Joined: Aug 03, 2003
Posts: 66
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.


Download a copy of <a href="http://www.javarules.com" target="_blank" rel="nofollow"><i>"Mastering The Fundamentals of The Java Programming Language"</i></a>
Anup Agrawal
Greenhorn

Joined: Jun 09, 2001
Posts: 19
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).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Setting Path and Classpath?
 
Similar Threads
javac is not recognized?
Help me to create batch file
why do I get NoClassDefFoundError????
NoInitialContextException
Problem compiling