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

Support for command line arguments in Application

XMLWordPrintable

      Through Application.launch() allows to pass command line arguments to the method, BUT there is no direct way to have access to those arguments from within Application.launch().

      Suggestions :

      - Either add accessor methods in Application to get access to a String[] or UnmodifiableList<String> or Set<String> that contains those arguments.

      - or make the Application class try various constructor for the initialization of the child class before defaulting to the constructor without argument.

      ie :

      public class Main extends Application {
         public Main (String[] args) {...}

       /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              Application.launch(Main.class, args);
          }
      }

      or

      public class Main extends Application {
         public Main (String... args) {...}

       /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              Application.launch(Main.class, args);
          }
      }

      or

      public class Main extends Application {
         public Main (List<String> args) {...}

       /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              Application.launch(Main.class, args);
          }
      }

      or

      public class Main extends Application {
         public Main (Set<String> args) {...}

       /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              Application.launch(Main.class, args);
          }
      }


      Currently the only way to have access to the command line arguments is to store them in a static member of the class.

            kcr Kevin Rushforth
            fbouyajfx Fabrice Bouyé (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: