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

Packaged Java applications do not receive command line arguments.

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_20"
      Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
      Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
      iMac2:~ russ$


      ADDITIONAL OS VERSION INFORMATION :
      OS/X 10.11.5

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Java(TM) SE Runtime Environment (build 1.8.0_20-b26)

      A DESCRIPTION OF THE PROBLEM :
      When the following program is packaged and installed in the Applications folder, then installed as a file open action either as a mime default or as the target of a folder open action, the program shows no arguments when it should show one or more arguments. I have tested it with several different scenarios. When run from the IDE with an argument supplied, it works as expected.

      package demomissingargs;

      import java.io.PrintWriter;
      import java.io.StringWriter;
      import javax.swing.JOptionPane;

      /**
       *
       * @author russ
       */
      public class DemoMissingArgs
      {

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args)
          {
              StringWriter sw = new StringWriter();
              PrintWriter pw = new PrintWriter(sw);
              pw.format("Num Args: %d\n",args.length);
              for (String s : args)
              {
                  pw.println(s);
              }
              JOptionPane.showMessageDialog(null, sw.toString(), "Args", JOptionPane.INFORMATION_MESSAGE);
              System.exit(0);
          }
          
      }

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the program shown, package as an Image Only, move the image to the Application's folder and set it as the default application handler for a file, then double click that file from the Finder.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program should show one argument and display the file name of the file chosen.
      ACTUAL -
      The program shows the number of arguments to be 0.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package demomissingargs;

      import java.io.PrintWriter;
      import java.io.StringWriter;
      import javax.swing.JOptionPane;

      /**
       *
       * @author russ
       */
      public class DemoMissingArgs
      {

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args)
          {
              StringWriter sw = new StringWriter();
              PrintWriter pw = new PrintWriter(sw);
              pw.format("Num Args: %d\n",args.length);
              for (String s : args)
              {
                  pw.println(s);
              }
              JOptionPane.showMessageDialog(null, sw.toString(), "Args", JOptionPane.INFORMATION_MESSAGE);
              System.exit(0);
          }
          
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found.

        Attachments

          Activity

            People

            Assignee:
            pardesha Pardeep Sharma
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: