Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6519476

-cp option in java.exe and javaw.exe is handled differently for wildcards(*)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • tools
    • x86
    • windows_2000

      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 ----------

            ksrini Kumar Srinivasan
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: