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




206 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. Still not running plz help... javac is not recognized as internal or external command... i have done all steps u said... please...

    ReplyDelete
  33. Hi Friend,

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

    ReplyDelete
  34. 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
  35. Very simple, easy to understand yet informative.. Thanks ..

    ReplyDelete
  36. 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
  37. 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
  38. @priti : You should have to try setting of jcreator :)

    Their may be problem of that side!!!

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

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

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

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

    ReplyDelete
  43. 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
  44. thank u very much.It's crystal clear!!

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

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

    ReplyDelete
  47. 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
  48. i have better than this

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

    ReplyDelete
  50. 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
  51. Great work!...really helpful :)

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

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

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

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

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

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

    ReplyDelete
  58. Easy to do. Thank u buddy

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

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

    ReplyDelete
  61. thank you very very much.......

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

    ReplyDelete
  63. ITS SUPERB VERY USEFULL TO ME
    THANX

    ReplyDelete
  64. Thanks dude ITS nice presentation

    ReplyDelete
  65. 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
  66. very nicely explanation!!!!!!!!!!!!!!!!

    ReplyDelete
  67. Thanks boss,nice explanation...

    ReplyDelete
  68. 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
  69. Thanks a lot its really great . Very usefull information

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

    ReplyDelete
  71. 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
  72. thank u so much......really great.

    ReplyDelete
  73. 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
  74. THNX BUDDIE....IT HELPS ALOT

    ReplyDelete
  75. yeaaaaaaaaaahhhh!!! it works. thanks

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

    ReplyDelete
  77. thankz.................its very helpful...

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

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

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

    ReplyDelete
  81. Excellent job....well defined!!!!

    ReplyDelete
  82. Thanx man really worked

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

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

    ReplyDelete
  85. It worked !!! superb Thanx

    ReplyDelete
  86. 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
  87. thanks , need new update like jdk 7

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

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

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

    ReplyDelete
  91. 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
  92. Thank you. Your article was really helpful.

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

    ReplyDelete
  94. 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
  95. AWESOME WOOOO!! thanks

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

    -Syed Mohsin Ahmed

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

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

    ReplyDelete
  99. 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
  100. Wonderful Bharat. Thanks a lot for you. You opened the gateway for me.

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

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

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

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

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

    ReplyDelete
  106. 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
  107. Thank u...Very easy Explonation..

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

    ReplyDelete
  109. 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
  110. Thanks bro its really help full for me in peak time.
    JEEVAN
    ecentric solutions

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

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

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

    ReplyDelete
  114. Thanks a lot......dear

    ReplyDelete
  115. thanks a lot!! it really worked

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

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

    ReplyDelete
  118. Thanks a lot......dear

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

    ReplyDelete
  120. You are execellent!!

    ReplyDelete
  121. Thanks sir,
    It is very helpful.

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

    ReplyDelete
  123. 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
  124. 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
  125. Dude. Its really helpful. Thanks a lot

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

    ReplyDelete
  127. Thanks u so much it was too good

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

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

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

    ReplyDelete
  131. thanks very much.....

    ReplyDelete
  132. Thank u soo much its really very helpfull

    ReplyDelete
  133. gret......
    thank u

    ReplyDelete
  134. brilliant link to starter ......

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

    ReplyDelete
  136. 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
  137. thankqqqq very muchhh sir.. it has helped me a lott..

    ReplyDelete
  138. 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
  139. 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
  140. 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
  141. 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
  142. good job ..it will help to beginers

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

    ReplyDelete
  144. thanks for your help with detailed sreen shot

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

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

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

    ReplyDelete
  148. 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
  149. Thank you so much.. Worked wonderful..:)

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

    ReplyDelete
  151. Thanks it's working...............:-)

    ReplyDelete
  152. Thanks it's working...............:-)

    ReplyDelete
  153. Thanks A lot Nice Way of Description representing it through Diagram Step by Step. Setting the Path and Class path in windows by marking with yellow in nice way. I have read the few posts in your blog. Simple to Nice way of description that any body can easily understand. I favor to that am describing the Setting the Path and Class path of Environmental Variables in Windows 8

    ReplyDelete
  154. Some common issues I have seen being faced by beginners is because they start using the IDE from day one.I have written a blog post for this only where I list the most common issues faced with regard to Classpath

    ReplyDelete

Powered by Blogger.