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 Response to "Setting PATH and CLASSPATH in Java in Windows7 & XP (How to set PATH variable in Java in Windows7 & XP)."

«Oldest   ‹Older   1 – 200 of 213   Newer›   Newest»
  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.

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

  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

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

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


  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

  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!

  9. this is the best works

  10. Thanks dear

  11. thanks ....... u had explained very clearly

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

  13. 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

  14. 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

  15. Cheers! Worked like a charm

  16. Your info came in handy..

  17. 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.

  18. i had a problem in compiling

  19. 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

  20. Thank you !! Really saved a lot of time !

  21. Really thanks ............... buddy

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

  23. thank you..very much.

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

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

  26. thanks a lot

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

  28. Its Not Working In My computer ...Do Reply..What to Do?

  29. This comment has been removed by the author.
  30. 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.

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

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

  33. Lovely post...keep rocking...;)

  34. great its working boss thankU

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

  36. Hi Friend,

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

  37. 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.

  38. thank u very very much dear....

  39. Very simple, easy to understand yet informative.. Thanks ..

  40. 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....??

  41. 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 :)

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

    Their may be problem of that side!!!

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

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

  45. thnk ya so much .,it was really simple

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

  47. 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...

  48. thank u very much.It's crystal clear!!

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

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

  51. Thanks a lot :)

  52. 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.

  53. i have better than this

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

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

  56. Great work!...really helpful :)

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

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

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

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

  61. Thank you very much....very very important your guideline....

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

  63. Easy to do. Thank u buddy


  65. Thank you very much

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

  67. thank you very very much.......

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


  70. Thanks dude ITS nice presentation

  71. 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

  72. Great......

  73. very nicely explanation!!!!!!!!!!!!!!!!

  74. Thanks boss,nice explanation...

  75. 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.

  76. Thanks a lot its really great . Very usefull information

  77. thanq so much yaar...........awesome blog

  78. 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.

  79. thank u so much......really great.

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


  82. yeaaaaaaaaaahhhh!!! it works. thanks

  83. Awesome post.....very detailed and helpful.

  84. a very informative one ......
    thanks a lot!

  85. thankz.................its very helpful...

  86. Grazie Roberto.

  87. Thanks - it was really useful. Gr8.

  88. It worked well for me...thanks...

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

  90. thank u very worked!!!

  91. Excellent job....well defined!!!!

  92. Thanx man really worked

  93. Very simple, easy to understand yet informative.. Thanks

  94. This comment has been removed by the author.
  95. It worked !!! superb Thanx

  96. 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

  97. thanks , need new update like jdk 7

  98. Really it is good information,i think it is useful.

  99. super Cool .. what a single shot answer.

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

  101. you are not suppose to create a new path , the existing path already has important "paths" i 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...

  102. Thank you. Your article was really helpful.

  103. u sir made my day.. :)

  104. Tnx ,,,,,this post...but i have problem....

    Exception in thread "main" java.lang.NoClassDefFoundError: hello/java
    Caused by: java.lang.ClassNotFoundException:
    at$ Source)
    at Method)
    at 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: Program will exit.



  106. AWESOME WOOOO!! thanks

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

    -Syed Mohsin Ahmed

  108. thnx dude, after seeing this it helps me alot..............

  109. thnx dude, after seeing this it helps me alot..............

  110. Thanks really a great work...

  111. Please tell me how to set Environment Variables for java 6 n tomcat 6

    plz plz plz help me... im very confused

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

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

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

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

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

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

  118. 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.

  119. Thank u...Very easy Explonation..

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

  121. 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

  122. Thanks bro its really help full for me in peak time.
    ecentric solutions

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

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

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

  126. Here is the step by step tutorial I follow to set PATH for Java in Windows 7 and Windows 8

  127. Thanks a lot......dear

  128. thanks a lot!! it really worked

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

  130. Very very thanks to you .It really works for me.

  131. Thanks a lot......dear

  132. Thanks a lot :)

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

  134. You are execellent!!

  135. Thanks sir,
    It is very helpful.

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

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

  137. extremely heplful a very hearty bharatsoft

  138. it really succeed. Thank you.

  139. 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.

  140. 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

  141. Dude. Its really helpful. Thanks a lot

  142. Thank you, it was easy to follow!

  143. Thanks u so much it was too good

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

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

  146. Thanks buddy, you made a great help!

  147. thanks very much.....

  148. Thank u soo much its really very helpfull

  149. brilliant link to starter ......

  150. I want do make class path as

  151. 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

  152. thankqqqq very muchhh sir.. it has helped me a lott..

  153. 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

  154. 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 .

  155. 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 .

  156. 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,

  157. good job will help to beginers

  158. Thank u very much... It helped me a lot

  159. thanks for your help with detailed sreen shot

  160. This Page has nothing in it
    check out

  161. tx very much to u ...expling with images supeb

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

  163. 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?

  164. Thank you so much.. Worked wonderful..:)

  165. So nice. I'm also thankful to YOU sir.

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

«Oldest ‹Older   1 – 200 of 213   Newer› Newest»

Post a Comment