Duplicate :
|
FULL PRODUCT VERSION : java version "1.7.0_03" Java(TM) SE Runtime Environment (build 1.7.0_03-b05) Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 5.2.3790] A DESCRIPTION OF THE PROBLEM : When using a singular classpath, e.g. java -cp lib/* my.package.MyClass the result is: Error: Could not find or load main class lib.first_file_in_folder.jar When adding one or more (empty) paths to the classpath, this error does not occur; e.g. -cp lib/*;lib/* or -cp lib/*; or -cp ;lib/* The error is always the same, stating that Java cannot find or load a class which is actually the first file in the specified folder. REGRESSION. Last worked in version 6u29 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Have a jar with some executable file in it, store it in a folder. 2. Use any command line (I haven't tested this on an OS other than Windows XP or Win7 ) and execute the following command: 3. Execute the class by adding the folder containing the jar to the classpath; java -cp path/to/folder/* TheClass EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - When using JDK 1.6 this error does not occur, the program would execute. ACTUAL - Java could not find or load the main class <some jar file on the classpath> ERROR MESSAGES/STACK TRACES THAT OCCUR : Error: Could not find or load main class lib.annotations-1.3.9.jar This happens to be the first jar file in my lib folder. REPRODUCIBILITY : This bug can be reproduced always. CUSTOMER SUBMITTED WORKAROUND : Add one or more (empty elements) to the classpath, simply adding a classpath separator is enough, e.g. -cp lib/*; over -cp lib/*