JDK-6519476 : -cp option in java.exe and javaw.exe is handled differently for wildcards(*)
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2007-01-30
  • Updated: 2010-04-04
  • Resolved: 2007-01-31
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
NA

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
There is a difference in handling  "-cp"  option in java.exe and javaw.exe with wildcard.
We can add all jar files in a directory to classpath using wildcard option. But this works only while using java.exe. Wildcard does not work in javaw.exe
Suppose  C:\Temp\lib contains two jar files a.jar and b.jar ,then we can use wildcard while specifying classpath.

e.g.
java -cp C:\Temp\lib\*  javaprogramname
When java.exe all the jars inside C:\Temp\lib are added to classpath.

javaw -cp C:\Temp\lib\*  javaprogramname
When using javaw.exe jars inside C:\Temp\lib are NOT added to classpath.






STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Suppose  C:\Temp\lib contains two jar files a.jar and b.jar

Then run the following program with java and javaw.

java -cp .;c:\Temp\lib\* ClassPathTest
This gives output as ".;c:\Temp\lib\a.jar;c:\Temp\lib\b.jar"
This is correct behaviour.

javaw -cp .;c:\Temp\lib\* ClassPathTest
This gives output as ".;C:\Temp\lib\*"
This is wrong behaviour. Wildcard options is ignored.


ClassPathTest.java
-----------------------------------------------------------------------------------------------
import javax.swing.JFrame;
import javax.swing.JTextPane;

public class ClassPathTest {

	public static void main(String args[]){
		JFrame frame = new JFrame("Test");
		JTextPane textpane = new JTextPane();
		frame.getContentPane().add(textpane);
		textpane.setText(System.getProperty("java.class.path"));
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(500,500);
		frame.setVisible(true);
	}

}

---------------------------------------------------------------------------------------



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
ClassPathTest.java
-----------------------------------------------------------------------------------------------
import javax.swing.JFrame;
import javax.swing.JTextPane;

public class ClassPathTest {

	public static void main(String args[]){
		JFrame frame = new JFrame("Test");
		JTextPane textpane = new JTextPane();
		frame.getContentPane().add(textpane);
		textpane.setText(System.getProperty("java.class.path"));
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(500,500);
		frame.setVisible(true);
	}

}

---------------------------------------------------------------------------------------

---------- END SOURCE ----------

Comments
EVALUATION This is a duplicate of 6510337, please see that bug for more information.
31-01-2007