Checking CLASSPATH on Windows
To check CLASSPATH variable is set on Microsoft Windows, run following command on command prompt
C:> echo %CLASSPATH%
If CLASSPATH variable is not set you will see %CLASSPATH% on windows system.
Checking CLASSPATH on Unix, Linux or Mac
To check CLASSPATH variable is set on Unix/Linux/Mac run following command on shell
$ echo $CLASSPATH
If CLASSPATH variable is not set you will see CLASSPATH: Undefined variable error on Unix/Linux/Mac systems.
Java versions Older then Java 6 does not support wildcard characters. Setting Multiple jars using wildcard in Java classpath are allowed in Java 6 and later versions.
For example, to specify all jar files in a directory “lib” the classpath entry should look like this lib/*
The wildcard entry (*) in classpath value will match only jar files NOT class files. To match both class files and JAR files in a same directory lib, you need to specify both values as shown below
Setting Multiple Jars in Classpath on Windows
Windows environment variable values are separated by semicolon, therefore you classpath entry would look like thislib/*;lib
Setting Multiple Jars in Classpath on Unix, Linux or Mac
Unix environment variable values are separated by colon, therefore you classpath entry would look like thislib/*:lib
Older version of Java
In older version of Java(older than Java 6), each jar file needs to be specified in the classpath. It can be a tedious and erroneous task if you are using many third party libraries.