 <p>Its becasue,Java CLASSPATH points to current directory denoted by <code>"."</code> and it will look for classes in the current directory.</p> <p>In case we have multiple directories defined in CLASSPATH variable, Java will look for a class starting from the first directory and only look the second directory in case it did not find the specified class in the first directory. Multiple directories are added in classpath with the help of <code>":"</code></p> <p>you have set classpath like </p> <pre><code>javac -classpath .:/path/to/graph/*:/path/to/graph/lib/* ErrorTest*.java </code></pre> <p>so using this command you are setting multiple directories in classpath.</p> <p><strong>JVM search directory in the order they have listed in CLASSPATH variable.</strong> </p> <p>In your case seems some classes are present in the current directory so if you are not providing current directory in classpath JVM searches in second path and then third but required class is not present so seems that it is not working</p>