Use System.getenv instead of System.getProperty. Note that you can also get the effective classpath for the current Java process with:

System.getProperty("java.class.path");

And that this value can, and in most cases will, be different from whatever your CLASSPATH environment variable is setup to be.

Answer from Perception on Stack Overflow
🌐
HowToDoInJava
howtodoinjava.com › home › java basics › java classpath
How to set CLASSPATH in Java - HowToDoInJava
February 23, 2023 - Anytime you wish to verify all path entries in CLASSPATH variable, you can verify using the echo command. //Windows c:/> echo %CLASSPATH% //Linux/Unix $ echo $CLASSPATH
🌐
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
Now to check the value of Java classpath in windows type "echo %CLASSPATH" in your DOS command prompt and it will show you the value of the directory which is included in CLASSPATH.
🌐
Muthu Saravanan
mshappylearning.wordpress.com › 2014 › 08 › 31 › java-path-and-classpath-settings-on-windows-command-prompt-system-variables
JAVA Path and Classpath Settings on Windows (command prompt / System Variables) | Muthu Saravanan
August 31, 2014 - Enter Variable name: CLASSPATH Variable value: your installed JDK directory/lib/*.jar eg: C:\Program Files (x86)\Java\jdk1.7.0\lib\*.jar and Press OK button.
🌐
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 - Your CLASSPATH environment variable should now be set. Hopefully this resolves the error you were dealing with. If you continue to get an error message, be sure you have a ; at the end of the line. Should you need to add an additional directory to the CLASSPATH variable simply add it after the semicolon (as you would the PATH environment variable).
🌐
Princeton CS
introcs.cs.princeton.edu › java › 15inout › classpath.html
Setting the Classpath in Java
How can I check the value of my CLASSPATH variable? Windows Command Prompt Type the following at the command prompt.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › tools › windows › classpath.html
2 Setting the Class Path
April 21, 2026 - If the CLASSPATH variable is set at system startup, then the place to look for it depends on your operating system: Windows 95 and 98: Examine autoexec.bat for the set command.
🌐
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.
🌐
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 in command prompt to set classpath from command prompt in Windows and Linux OS.
🌐
Coderanch
coderanch.com › t › 355190 › java › Displaying-CLASSPATH-Values
Displaying CLASSPATH's Values (Servlets forum at Coderanch)
September 14, 2002 - This works on any Windows OS as well as on Unix/Linux. I thought this is the only way. I use "set PATH" and "set CLASSPATH" to display those values. If you just enter "set" you see them all.
🌐
Edureka
edureka.co › blog › set-java-classpath
How To Set Classpath In Java | Java Path And Classpath | Edureka
June 19, 2023 - Run Command Prompt 1. Type in the following echo %JAVA_HOME% This will echo the directory path of JAVA_HOME or it will echo nothing if Variable is not set. echo %JAVA_HOME% ... To check version type java -version: 1.
🌐
Oracle
docs.oracle.com › javase › › 7 › docs › technotes › tools › windows › classpath.html
Setting the class path
The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.
🌐
Javainterviewpoint
javainterviewpoint.com › how-to-set-classpath-for-java-in-windows
javainterviewpoint.com
June 5, 2015 - Own it today for $1,911, or select Lease to Own or make an offer · Free transaction support
🌐
Refreshjava
refreshjava.com › java › what-is-path-and-classpath
Path and Classpath in Java - Set path in Java - RefreshJava
The CLASSPATH variable is a way ... value, first you can set this as an environment variable in OS, second you can use -cp or -classpath command line option in command window itself....