Add the appropriate javac path to your PATH variable. java.exe will be found under the bin directory of your JDK. E.g.

SET PATH=%PATH%;C:\Program Files (x86)\Java\jdk1.6.0_05\bin
Answer from krock on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › environment › paths.html
PATH and CLASSPATH (The Java™ Tutorials > Essential Java Classes > The Platform Environment)
If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).
🌐
Princeton CS
introcs.cs.princeton.edu › java › 15inout › classpath.html
Setting the Classpath in Java
Go to that directory and compile them. ... From DrJava, choose the menu option Edit -> Preferences -> Resource Locations -> Extra Classpath -> Add and select C:\introcs. Click the Apply button, then the OK button. To set the classpath for the Windows XP Command Prompt:
🌐
Oracle
docs.oracle.com › javase › › 7 › docs › technotes › tools › windows › classpath.html
Setting the class path
The class path is the path that the Java runtime environment searches for classes and other resource files. The class search path (more commonly known by the shorter name, "class path") can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting ...
🌐
Blogger
javarevisited.blogspot.com › 2011 › 01 › how-classpath-work-in-java.html
How to Set Classpath for Java on Windows and Linux? Steps and Example
You can also set classpath in windows by using DOS commands like: $ set CLASSPATH=%CLASSPATH%;JAVA_HOME\lib; This way you can set the classpath in Windows XP, Windows 2000, or Windows 7 and 8, 10 as they all come with a command prompt.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › tools › windows › classpath.html
2 Setting the Class Path
April 21, 2026 - The class path is the path that the Java Runtime Environment (JRE) searches for classes and other resource files. ... The class search path (class path) can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable.
🌐
Baeldung
baeldung.com › home › java › core java › java classpath syntax in linux vs. windows
Java Classpath Syntax in Linux vs. Windows | Baeldung
January 8, 2024 - # On Windows system: CLASSPATH="PATH1;PATH2;PATH3" # On Linux system: CLASSPATH="PATH1:PATH2:PATH3" We’ve learned that the classpath separator can be different depending on the operating system. However, if we take a closer look at the Java man page on Linux, it says the classpath separator is the semicolon (;).
🌐
Chilkat
chilkatsoft.com › java-classpath-Windows.asp
Java JAR Archives and classpath on Windows
String classpath = System.getProperty("java.class.path"); System.out.println(classpath); Modify the CLASSPATH environment variable to also include the directory containing the JAR archive. This is typically done via the Windows Computer-->Properties-->Advanced dialog.
Find elsewhere
🌐
Edureka
edureka.co › blog › set-java-classpath
How To Set Classpath In Java | Java Path And Classpath | Edureka
June 19, 2023 - Moving on with this article on How to Set Java Classpath? 1. In the Environment Variables window under System variables click on the path. 2. Click Edit. 3. In the Edit environment variable window click New.
🌐
HowToDoInJava
howtodoinjava.com › home › java basics › java classpath
How to set CLASSPATH in Java - HowToDoInJava
February 23, 2023 - If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) console or simply %CLASSPATH% printed in the windows command prompt. Happy Learning !! ... There is a subtle but serious bug in the code outlined in section 3 that can be instructive to understanding that classpath is where JVM looks for all classes and not just for dependant classes. The first statement “$ javac –classpath C:\dependency\framework.jar MyApp.Java” compiles fine and places the MyApp.class file in the current directory.
🌐
HowToDoInJava
howtodoinjava.com › home › java examples › java – set classpath from command line
Java - Set Classpath from Command Line
January 25, 2022 - Learn to use the -classpath or -cp option to set the Java classpath from the command prompt in Windows and Linux OS.
🌐
Medium
medium.datadriveninvestor.com › java-classpath-know-it-and-use-it-correctly-2cf6e4dc87ee
Java Classpath, know it, and use it correctly! | by Tom Henricksen | DataDrivenInvestor
June 29, 2022 - Although we discussed the PATH before here we haven’t talked about CLASSPATH. The CLASSPATH helps the Java Virtual Machine or JVM know where to look for resources. The PATH is geared toward the operating system. If you are on Windows it needs to know where to look for the file or application you are running.
🌐
Princeton
cs.princeton.edu › courses › archive › fall97 › cs461 › jdkdocs › tooldocs › win32 › classpath.html
classpath - Environment Variables
To use both JDKs simultaneously, you can run them from separate DOS windows each having its own value for CLASSPATH. If you are running only one at a time, you should switch the value of CLASSPATH as appropriate. ... Some of the Java tools such as java, javac, and javah have a -classpath option which can be used to override the path or paths specified by the CLASSPATH environment variable.
🌐
Blogger
javarevisited.blogspot.com › 2013 › 02 › windows-8-set-path-and-classpath-java-windows-7.html
How to set Java Path and Classpath in Windows 7, 8 and Windows 10 - Tutorial
JDK bin directory contains javac and java commands to compile and run Java programs. CLASSPATH is a little different than Path and it's used by JVM rather than Operating System to load classes at runtime.
🌐
Wikipedia
en.wikipedia.org › wiki › Classpath
Classpath - Wikipedia
May 30, 2026 - The environment variable named CLASSPATH may be alternatively used to set the classpath. For the above example, we could also use on Windows: D:\myprogram>set CLASSPATH=D:\myprogram D:\myprogram>java org.mypackage.HelloWorld
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-set-classpath-in-java
How to Set Classpath in Java? - GeeksforGeeks
July 23, 2025 - It allows the system to locate the Java executables to compile and run programs. The CLASSPATH variable is used to specify the location of the Java class files and libraries required for the program.
🌐
Full Boar LLC
fullboarllc.com › home › setting the classpath variable in windows 10
Setting the CLASSPATH Variable in Windows 10 - Full Boar LLC
February 15, 2021 - Note, you do not always need to modify the CLASSPATH variable. As an alternative you can simply pass the path of the JAR file to java using the -cp command line argument. You can find more about that here. Follow the steps below to add the CLASSPATH variable to your Windows 10 environment variables:
🌐
Lenovo
lenovo.com › home
Java Classpath: Definition, Usage, Options & Best Practices | Lenovo US
On Unix-based systems, you can use echo $CLASSPATH, while on Windows, you can use echo %CLASSPATH%. Alternatively, for a specific Java program, running java -cp or checking IDE configurations can reveal the classpath currently in use for that compilation or execution instance.