Difference between PATH and JAVA_HOME?

Can anyone tell me the difference (if any) between setting your PATH variable to point to your jdk, and setting the JAVA_HOME to do the same thing? Does one take precedence over the other?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is not the same path
The setting the path environment is so your programs/compilers can run smoothly, like where ever you are you can always call java or javac, (not needing to type C:\javasdk\bin\java)

The JAVA_HOME tells where java are, C:\javasdk, so, java programs knows where to find jars and wich java to use (if you have multiple installs)

the path must include: C:\javasdk\bin
and you must have JAVA_HOME=C:\javasdk

where javasdk is your installation

yes both r same..........thats what i think .........as both looks for same thing........
yes both r same..........thats what i think .........as both looks for same thing........
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

They aren't the same!!

one points to "bin" directory and the other to "installation directory" of your java installation
the bin is where all the java components are stored:
such as
javac, java etc.
The other is the home directory of java i.e
where the base java directory is installed
so if you have java installed in the javajdk directory when you type java_home you would get

or if you have it installed in your temp directory on your c drive when u type java-home you would get:

it points to the home directory think of unix when you think of home, where as setting the path is like setting the path for any application so that if you were to type java from a command line it would be able to recognise where java was as you have set the path as for example;
which contains the exe called java

i.e the path _TELLS_ your computer where the files are stored that you use to run java.
smyers2003Author Commented:
Thank you, everyone. So, if I set my PATH to point to C:\jdk1.2.2\bin, and then I set my JAVA_HOME to point to C:\j2sdk1.4.1_02, then my system will use the 1.2.2 JRE but point at the newest jars, components, etc. from the newest JDK (j2sdk1.4.1_02). Is that correct?
yes that is correct it will point to 1.2.2.

No worries!
The best thing for you to do is test this out, make sure however its under a development machine you do it though, check your bin directory and you will see some of the following files:
javap.exe, jar.exe, javac.exe, java.exe appletviewer.exe etc, if you set your path i.e
in autoexec.bat or in windows xp you can do it through panel.
like such:  

set path = c:\jdk1.2.2\
it will use the java.exe file from the JDK 1.2.2 installation i.e this will use the apis from jdk1.2.2 not 1.4, if you do java_home it will give you the directory that you have java installed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smyers2003Author Commented:
Thank you, Pronane, and I will accept your answer and hopefully you will get the 50 points....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.