File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Problems setting PATH environment variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problems setting PATH environment variable" Watch "Problems setting PATH environment variable" New topic

Problems setting PATH environment variable

Yong Lee

Joined: Apr 20, 2008
Posts: 6
I was able to compile and run the HelloWorldApp, but to compile it I had to specify the entire path:


I understand that if I update the PATH variable, I won't have to specify the entire path every time I run the JDK executables.

To update the PATH variable, I followed the instructions from the installation notes. However, I had to add the PATH variable to both User Variables and System Variables...I simply chose 'New', named the variable 'PATH', and set the value to be 'C:\Java\jdk1.6.0_06\bin'. I did this for both User and System Variables.

I STILL have to specify the entire path in order to compile and run...what did I do wrong? Also, what's the difference between the PATH var. and the CLASSPATH var? I noticed that the value for my CLASSPATH var. (which is only under System Variables, not User Variables) is for an older JRE folder:

.;C:\Program Files\JavaSoft\JRE\1.3.1\lib\ext\

What should I update this value to? (the current version of JRE I have installed, JRE1.6.0_06, does not have an 'ext' directory, or any equivalent QTJava file) I'm sorry for such a long question, but I would REALLY appreciate any help!!
Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265


A couple of questions:

1. did you open a new command window after setting your Path variable? If you used the existing window, that would explain why it didn't pick up the change.

2. after opening a new command window, type path and see what it returns. is the java bin directory on that path? if not, there's a mistake somewhere in how you set up the variables.

I'm a bit surprised you don't have an existing path variable.

I'd just delete the old classpath entry and not worry about replacing it.

There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Kuldeep Singh

Joined: Apr 20, 2008
Posts: 3

Regards,<br />kuldeep<br /> <br />May be.!! Alot of People are responsible for your Success but you are the ONE responsible for your FAILURE.
Yong Lee

Joined: Apr 20, 2008
Posts: 6
Muchas gracias!

I didn't realize that I needed to open a new command window...when I tried it today, it worked!

Question: when I type path, here's what's returned:


Why is the path repeated? Is it to show the paths of both User and System Variables?

Also, why not replace the CLASSPATH variable after deleting it? What does this variable do?

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150

"Kuldeep withDreams", please check your private messages. You can see them by clicking My Private Messages.

Yong: I'm not sure how this works on Windows (I use Linux most of the time), but yes, probably it's repeated because you put it in the User as well as in the System variables. You only need to put it in one of those two places (User if you want it for your login only, or System if you want to set it for all people who might use your computer).

CLASSPATH tells Java where to look for class files. Normally, with newer Java versions, you don't need to set it; Java will look for class files in the current directory if it's not set. You can also specify the classpath on the command line instead of as an environment variable, for example:

java -classpath C:\myproject\classes org.mypackage.MyMainClass

For more info, see this in our FAQ: How to set the classpath
[ April 22, 2008: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Yong Lee

Joined: Apr 20, 2008
Posts: 6
Thank you, Jesper, for your reply. I do have another question:

If the CLASSPATH variable tells Java where to look for class files, does that mean you can put .java files in different directories (other than the directory where your Java excutables: javac, etc) are located? If you do this, how do you other words, how would you compile a .java file that's located in a directory other than the current directory? Is it a bad practice to do this? Thanks!
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Please check your private messages.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11313

it IS a bad practice to put your code/class files in the same dir as the JVM stuff. you really don't want to mix that stuff up.

generally, you'll create some kind of 'projects' directory, with sub-folders for each program.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: Problems setting PATH environment variable