Searching on the classpath

Whether -classpath or CLASSPATH is used, the classpath value presents the list of .class and .jar files. The javac and java tools always search the list from left to right. If the same .class file is listed several times (inside several folders or .jar files, for example), then only its first copy will be found. If several versions of the same library are included in the classpath, it may cause a problem. For example, a newer version of a library might never be found if it is listed in the classpath after the older version.

Also, the libraries themselves can depend on other .jar files and their particular versions. Two different libraries may require the same .jar file, but of different versions.

As you can see, with many files listed on the classpath, their management can quickly become a full-time job.  The good news is that you probably don't need to worry about it, because IDE will set the classpath for you.