Home » Java Tutorial » How to set path and classpath variable for java in Windows

How to set path and classpath variable for java in Windows

Hello friends, In this post I am going to help you learn “How to set path and classpath variable for java in Windows” . Because Selenium WebDriver Using Java binary will always needs Java in classpath to execute your written selenium scripts.

So let’s starts

1-      Download  recent version of Java SE Development Kit

(You can download java SE

2-      Install JDK  and by Default Java installs at at this place  C:/Program Files(X86)/Java

3-      Java folder contain two folder of name jdk1.6.0_20 and jre6

4-      Now we will set the classpath and path for java in our windows machine

5-      Right Click on My Computer

6-      Now click on Advanced System Setting.

Java Classpath


7-      Click on Environment Variables on next window that appears after clicking Advanced System Setting.

Environment Variable in Windows

8-      Click on New  under system variable on Environment Variables Window


9-      A new window for New System Variable will open

10-   Before Variable Name  write path

11-   Before variable value type C:/Program Files(x86)/Java/jdk1.6.0_20/bin


12-   Click on Ok
13-   Now to set classpath again click on New and again New System Variables  will appear

14-   Enter

Variable name = classpath and Variable Value = C:/Program Files/Javajdk1.6.0_20/lib


15-   Now click Ok  and again click Ok on Environment Variables

16-   Finally we have set path and classpath  and now start you java coding  best of luck

I think you have learn enough and you would be able to “Set path and classpath variable for Java in Windows”

Note:  Now version might be 11 or something but basic steps will remain same.



14 thoughts on “How to set path and classpath variable for java in Windows”

  1. the program is compiling bt can’t run giving the error could not find the main class nd a jni error also give exception in thread main..pls tell the soln.

  2. it does not work,when i write javac then java compiler will run but file does not when i write javac file.java it gives error cannot read file

  3. Pingback: How To Fix Java Windows 7 Path Errors - Windows Vista, Windows 7 & 8

  4. Pingback: Selenium WebDriver – Installation & Configuration | Bimarian Blog

  5. Wild cards were introduced from Java 6 . Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR.

    java -cp “lib/*” %MAINCLASS%
    Where %MAINCLASS% is the class containing your main method.

    More on…Path and ClassPath


  6. Pingback: Launch Chrome Browser Using WebDriver

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Scroll to Top
%d bloggers like this: