Setting PATH and CLASSPATH in Java in Windows7 & XP (How to set PATH variable in Java in Windows7 & XP)

Hi friends, 
Today I will show you how can you set Java path and Class Path on windows 7. 

If you want to see the VIDEO you can go through this link directly to know how to set path and class path in windows 7  , Or you can continue to the post below.....


First I will check if Java is installed on my machine or not, for this press CTRL+R keys .
and type cmd.  Command prompt will open. just type java  there as shown below.



Now as we can see we don't have Java installed on our machine we will install java first.

for this you can download Java from there official website (Donwlaod From Here)   or if you already have setup just install that as shown below




Now as Java is successfully installed we will proceed to set PATH and CLASSPATH, For this go to MY COMPUTER and right click on My computer icon as shown below and select ADVANCE SYSTEM SETTINGS .



Now a new window will open as shown below , in this window select ENVIRONMENT VARIABLES click on it as shown.


Again one new window will open that will contain all the PATH  and CLASSPATH  variables for the system as shown below 


Here you have to select Path as shown in above picture and click on edit. Now we need to copy the path of Java's bin folder to this place. below picture shows where to go for the bin folder.


After copying this path now again we will move back to our Environment Variable window ,
Now we need to paste this path there, So just type a semi colon(;) and paste the above path we copied to that window and press OK as shown below.

Now it will look like this


Finally we are done with setting PATH variable for Java, now we will proceed to set CLASSPATH,
Now again go to Environment variable window and inside CLASS window click on NEW as shown below.



When you will click here, it will open a new window. you need to type CLASS in variable name and Java's lib folder path as shown below.


To get the lib folder path search for this location as shown in below image and copy it.





Now we are done, just copy and paste the following Path and click on OK button and exit from all windows.  Now open command prompt and type Java - verison as shown below, And it will tell you the current Java version installed on your system







I also made a video on HOW CAN WE SET PATH AND CLASS PATH on WINDOWS 8. Please go through below video for more detail




213 comments:

  1. Its really very informative and a brief one. Although people know how to set path of java in xp but most doesnt know in window 7. This tutorial will help people greatly. This is ur first tutorial but u did like the professionals.

    ReplyDelete
  2. This is the only ultimate solution in Windows 7 i think, i tried many but only this one worked. Thanks Qaiser Imam.

    ReplyDelete
  3. offa after doing this i went to cmd and typed cd,,,and javac but it is showing me tht javac is not an external or internal command plz help me

    ReplyDelete
  4. Thanks for your solution! It really works!!! Thanks again!!!

    ReplyDelete
  5. if u are getting "not an internal or external command" then please first install JAVA or JRE

    ReplyDelete
  6. U HAVE EXPLAINED THIS VERY NICELY
    I APPRECIATE UR WORK
    VERY NICE

    ReplyDelete
  7. after doing this i went to cmd and typed cd,,,and javac but it is showing me tht javac is not an external or internal command plz help me

    ReplyDelete
  8. Thanks! That worked, but in my case I had to use the jre6 folder. I had the same issue as the "anonymous" person above, and what I was omitting to do, is close the cmd window and reopen... Sometimes it's easy to be stuck because of details like that!

    ReplyDelete
  9. this is the best solution.it works

    ReplyDelete
  10. thanks ....... u had explained very clearly

    ReplyDelete
  11. after this process i went to cmd and typed javac ,its showing javac is not an internal or external cmmand

    ReplyDelete
  12. after this process i went to cmd and typed javac ,its showing javac is not an internal or external command ,what to do plzzzzzz help me

    ReplyDelete
  13. after doing this i went to cmd and typed cd,,,and javac but it is showing me tht javac is not an external or internal command plz help me

    ReplyDelete
  14. Cheers! Worked like a charm

    ReplyDelete
  15. Your info came in handy..
    Cheers!!!

    ReplyDelete
  16. I appreciate u friend. Ur explanation was simple, detailed n straigtforward. I av been struggling with the installation for a long time.
    Thank u for ur assistance.

    ReplyDelete
  17. i had a problem in compiling

    ReplyDelete
  18. no need for all this just type the command: set path=%path%;C:\Program Files\Java\jdk1.7.0_01\bin in variable value in user variable.
    variable name=path

    ReplyDelete
  19. Thank you !! Really saved a lot of time !

    ReplyDelete
  20. Really thanks ............... buddy

    ReplyDelete
  21. Thanks a lot for the information. I have set up path. It is working fine.

    ReplyDelete
  22. thank you..very much.

    ReplyDelete
  23. thanks you for your effort. its working. thanks a lot.
    Gayantha Sri Lanka

    ReplyDelete
  24. Thank you so much. Spend about 3 days on this. I was getting fraustrated already.

    ReplyDelete
  25. Thanks for this, a very simple and clear set of instructions.

    ReplyDelete
  26. Its Not Working In My computer ...Do Reply..What to Do?
    is

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Guys I Followed The Similar Steps...But Still Its Not Working, when I run da command javac on Command Prompt.
    i Have Installed JDK1.7 and My OS is Windows7. Do post Suggestions..
    Its So Urgent For Me.

    ReplyDelete
  29. Still not running plz help... javac is not recognized as internal or external command... i have done all steps u said...
    help
    plzzzzzzzzzzzzzzz

    ReplyDelete
  30. wow what a help site this is awesome thanks for the given very useful snap shots
    thanks again...,

    ReplyDelete
  31. Lovely post...keep rocking...;)

    ReplyDelete
  32. great its working boss thankU

    ReplyDelete
  33. Still not running plz help... javac is not recognized as internal or external command... i have done all steps u said... please...

    ReplyDelete
  34. Hi Friend,

    it worked. Thankyou a lot!!! After giving all the above mentioned tips for java,javac is worked.

    ReplyDelete
  35. i use a jCreator pro bat when i m trying to run or compile the program its writing invalid path "C:\Program Files\Java\jdk1.5.0\bin" . bt when i am COMPILING same program in command prompt its executing .CAN U PLZZ HELP ME TO GET RID OF MY PROBLEM.

    ReplyDelete
  36. thank u very very much dear....

    ReplyDelete
  37. Very simple, easy to understand yet informative.. Thanks ..

    ReplyDelete
  38. THANKS a LOT....It WOrked.....I had set the path earlier also by set path command ....i had never set the class and Lib path....but thanks to your tutorial its working now.....Can you please elaborate why we have to set the class path....??

    ReplyDelete
  39. If you ARE trying this steps and an error called "javac is not an external or internal command".. Then you need to install java and remember install the latest one..You will get your solution :)

    ReplyDelete
  40. @priti : You should have to try setting of jcreator :)

    Their may be problem of that side!!!

    ReplyDelete
  41. thank u so much dear..hop'g more help'g docs like dis frm u...

    ReplyDelete
  42. is .; symbols are necessary before the path and classpath?

    ReplyDelete
  43. thnk ya so much .,it was really simple

    ReplyDelete
  44. yes this ; symbols are necessary before the path and class path, because its separates other paths from java path.

    ReplyDelete
  45. For Java 1.5 or old release you have to set path as well as class path. But after java 1.5 you not need not to set class path, only path is enough...

    ReplyDelete
  46. thank u very much.It's crystal clear!!

    ReplyDelete
  47. thanxx .... a lot for this post .. it helped me a lot to solve this problem.. :) :) !!!!

    ReplyDelete
  48. This is the best tutorial for the topic i hv seen till date. Thanks a ton!!

    ReplyDelete
  49. Thanks a lot :)

    ReplyDelete
  50. Thank you for a high quality, first-time-user appropriate, very helpful tutorial on how to get past this. So many other sites explain it like as if you should already know, but yours helps even us newbies that don't know.

    ReplyDelete
  51. i have better than this

    ReplyDelete
  52. I am trying to set the path for Java 3d! path is already set for java sdk what to do for java 3d??

    ReplyDelete
  53. In my system there is no user variable called "class" in environment variables dialog box.. how to create it.. will u help on this..??

    ReplyDelete
  54. Great work!...really helpful :)

    ReplyDelete
  55. I installed java 7.1 v.. nd jre too.. bt im unable to set the path..can any one help me out??

    ReplyDelete
  56. Thanks for sharing the information. It helped me a lot!! :)

    ReplyDelete
  57. Oh...god thnx!!!It really worked!!!I'm so glad for this.:)

    ReplyDelete
  58. thanks a lot buddy it was really helpful i was very much vexed with it

    ReplyDelete
  59. Thank you very much....very very important your guideline....

    ReplyDelete
  60. excellent approach .i search many things for path and class setting but this was perfect.

    ReplyDelete
  61. Easy to do. Thank u buddy

    ReplyDelete
  62. ITS VERY USEFUL THNK YOU VERY MUCH...............

    ReplyDelete
  63. Thank you very much

    ReplyDelete
  64. that works for sure....
    thank you friend.. sampath from Sri Lanka

    ReplyDelete
  65. thank you very very much.......

    ReplyDelete
  66. Thank you very much its very good to understand by seeing screen shots of how to set java path

    ReplyDelete
  67. ITS SUPERB VERY USEFULL TO ME
    THANX

    ReplyDelete
  68. Thanks dude ITS nice presentation

    ReplyDelete
  69. thnkss a lot frm the bottom of my heart... i m alwys cnfused abt this class and path bt u give me the proper giudance thnxx once again

    ReplyDelete
  70. very nicely explanation!!!!!!!!!!!!!!!!

    ReplyDelete
  71. Thanks boss,nice explanation...

    ReplyDelete
  72. Thanks for this,but the only way to work with on my computer is to delete the dot and the semi-colons before both path... Maybe the wrong way. I'll see soon certainly and sorry for the 's'. Bye.

    ReplyDelete
  73. Thanks a lot its really great . Very usefull information

    ReplyDelete
  74. thanq so much yaar...........awesome blog

    ReplyDelete
  75. It's not working in window 7 64 bits and 32 bits O.S.
    Nothing helped.
    Please suggest your idea behalf of this problem... and send me result at 9179466920.

    ReplyDelete
  76. thank u so much......really great.

    ReplyDelete
  77. Thanks a lot buddy...it helped and worked for windows 7 ultimate 64 bit....great job by highliting after taking screen shots...thanks for taking so much pain...

    ReplyDelete
  78. THNX BUDDIE....IT HELPS ALOT

    ReplyDelete
  79. yeaaaaaaaaaahhhh!!! it works. thanks

    ReplyDelete
  80. Awesome post.....very detailed and helpful.

    ReplyDelete
  81. a very informative one ......
    thanks a lot!

    ReplyDelete
  82. thankz.................its very helpful...

    ReplyDelete
  83. Thanks - it was really useful. Gr8.

    ReplyDelete
  84. This is the best tutorial for the topic i hv seen till date. Thanks a ton!!

    ReplyDelete
  85. thank u very much...it worked!!!

    ReplyDelete
  86. Excellent job....well defined!!!!

    ReplyDelete
  87. Thanx man really worked

    ReplyDelete
  88. Very simple, easy to understand yet informative.. Thanks

    ReplyDelete
  89. This comment has been removed by the author.

    ReplyDelete
  90. It worked !!! superb Thanx

    ReplyDelete
  91. if i run it as java -classpath . classfilename ,its working.... but if i just run it as java classfilename i get the error Exception in thread "main"
    java.lang.NoClassDefFoundError :classfilename what to do???please reply fast

    ReplyDelete
  92. thanks , need new update like jdk 7

    ReplyDelete
  93. Really it is good information,i think it is useful.

    ReplyDelete
  94. super Cool .. what a single shot answer.

    ReplyDelete
  95. It is really very very informative and the way of presentation is very good.

    ReplyDelete
  96. you are not suppose to create a new path , the existing path already has important "paths" i it.eg most cmd commands are gotten through the path ie System 32.......use edit , then add the path and afterwards add a semicolon. for those who used new notice that you cannot use normal commands on ur cmd window eg (shutdown -s)Try it...

    ReplyDelete
  97. Thank you. Your article was really helpful.

    ReplyDelete
  98. u sir made my day.. :)

    ReplyDelete
  99. Tnx ,,,,,this post...but i have problem....

    D:\java>java hello.java
    Exception in thread "main" java.lang.NoClassDefFoundError: hello/java
    Caused by: java.lang.ClassNotFoundException: hello.java
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: hello.java. Program will exit.

    D:\java>

    ReplyDelete
  100. TNX MAN UR DE BEST

    ReplyDelete
  101. AWESOME WOOOO!! thanks

    ReplyDelete
  102. Thanks a ton, JAVA made my day. all is well.. :-)

    -Syed Mohsin Ahmed

    ReplyDelete
  103. thnx dude, after seeing this it helps me alot..............

    ReplyDelete
  104. thnx dude, after seeing this it helps me alot..............

    ReplyDelete
  105. Please tell me how to set Environment Variables for java 6 n tomcat 6
    CLASSPATH
    PATH
    n CATALINA_HOME
    variables...

    plz plz plz help me... im very confused

    ReplyDelete
  106. Wonderful Bharat. Thanks a lot for you. You opened the gateway for me.

    ReplyDelete
  107. Dude... i am unable to run JDBC programs in windows 7... pls help me...

    ReplyDelete
  108. thank you soo much. now i can do my java programming in a easy manner

    ReplyDelete
  109. i am scjp cerified but dont know in depth.....thanks linke is awsome..have clicked on adds...as you said~~`

    ReplyDelete
  110. while compiling it is showing that cannot read java what do you think is the problem plz help me

    ReplyDelete
  111. Thankyou very much..!!!
    It's working now....I'm Soooo Hapyyy..
    Sri Lanka

    ReplyDelete
  112. After doing the above, JAVA command should work.

    JAVAC might not work thought, if you do not have a JDK installed.
    This is because your computer does not have the file JAVAC.exe anywhere. Its not about the path, its about the file. Install some JDK and repeat the process.

    ReplyDelete
  113. Thank u...Very easy Explonation..

    ReplyDelete
  114. good so nice uneducated people also understand well its very user friendly thanks thanks a lot

    ReplyDelete
  115. What is the difference between creating a new variable CLASS & setting it Vs. creating a system variables CLASSPATH pointing to C:\Program Files\Java\jre7\lib

    ReplyDelete
  116. Thanks bro its really help full for me in peak time.
    JEEVAN
    ecentric solutions

    ReplyDelete
  117. wowwwwww...........thanx frnd..its worked and helpd us a lot...blast..

    ReplyDelete
  118. That Mr. Bean shit on the side there? Yeah... That's REALLY goddamn annoying.

    ReplyDelete
  119. As another comment point it out, should you edit your existing path instead of creating a new variable path?

    ReplyDelete
  120. Thanks a lot......dear

    ReplyDelete
  121. thanks a lot!! it really worked

    ReplyDelete
  122. hoooh thank you so much!
    you gave screenshots and it's so relieving <3

    ReplyDelete
  123. Very very thanks to you .It really works for me.

    ReplyDelete
  124. Thanks a lot......dear

    ReplyDelete
  125. Thanks a lot :)

    ReplyDelete
  126. You're the hero I needed, but did not deserve. thanks.

    ReplyDelete
  127. You are execellent!!

    ReplyDelete
  128. Thanks sir,
    It is very helpful.

    ReplyDelete
  129. Exception in thread "main" java.lang.NoClassDefFoundError: student/java,,,

    error is coming . what is the problem ,. my code is correct

    ReplyDelete
  130. extremely heplful a very hearty thanks..........to bharatsoft

    ReplyDelete
  131. I need both java 6 and java 7 for 2 different programs. I followed your instructions and set the path for java7 but now the other program keeps comomg up as 7 and I need 6 for the other.

    ReplyDelete
  132. your instructions for setting the path were great and very helpful. I posted your site to the coordinator. But now I need to use java 6, still on my machine for the other one

    ReplyDelete
  133. Dude. Its really helpful. Thanks a lot

    ReplyDelete
  134. Thank you, it was easy to follow!

    ReplyDelete
  135. Thanks u so much it was too good

    ReplyDelete
  136. Thanks bro.... At last it worked in my Win 7.... thanks.. Thank u very much....

    ReplyDelete
  137. thnx dude... this is the most informative and "TRULY WORKING" process i came across so far!!

    ReplyDelete
  138. Thanks buddy, you made a great help!

    ReplyDelete
  139. thanks very much.....

    ReplyDelete
  140. Thank u soo much its really very helpfull

    ReplyDelete
  141. brilliant link to starter ......

    ReplyDelete
  142. I want do make class path as
    C:\test

    ReplyDelete
  143. guys plz help when i am compiling the java program i am getting javac is not reognised as internal or external command .my java version is jdk1.7,my os is windows 7 32 bit .plz help meeeeeeeeeeeeeeeeee its very urgent

    ReplyDelete
  144. thankqqqq very muchhh sir.. it has helped me a lott..

    ReplyDelete
  145. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new post, once again hats off to you! Thanks a lot once again, Regards, Difference Classpath and Path

    ReplyDelete
  146. i installed java 7 version .so i saw only jre7 file folder and i created path also but after running java file cmd is displaying javac is not recognised as an internal or external command.plse give me the solution .

    ReplyDelete
  147. i installed java 7 version .so i saw only jre7 file folder and i created path also but after running java file cmd is displaying javac is not recognised as an internal or external command.plse give me the solution .

    ReplyDelete
  148. Hi,
    Thanks a LOT for giving a detailed pictorial view of setting Path and Classpath for Java.
    It worked for me.
    All the Best for your future endeavors.

    Thanks and Regards,
    Chaitanya

    ReplyDelete
  149. good job ..it will help to beginers

    ReplyDelete
  150. Thank u very much... It helped me a lot

    ReplyDelete
  151. thanks for your help with detailed sreen shot

    ReplyDelete
  152. This Page has nothing in it
    check out
    http://www.ntu.edu.sg/home/ehchua/programming/java/J9c_PackageClasspath.html

    ReplyDelete
  153. tx very much to u ...expling with images supeb

    ReplyDelete
  154. i need to set 'path' 'classpath' in cmd i.e,windows7

    ReplyDelete
  155. I followed teh instructions step by step, and after all that when I go to CMD and type java-version its says its not recognixed as an internal or external command. Any further instructions on what to do?

    ReplyDelete
  156. Thank you so much.. Worked wonderful..:)

    ReplyDelete
  157. So nice. I'm also thankful to YOU sir.

    ReplyDelete
  158. hi..Im student from Informatics engineering, this article is very informative, thanks for sharing :)

    ReplyDelete

Powered by Blogger.