0

Right click on the project (console/desktop applications that use the main() method as an entry point), select the properties option from the sub-menu, select the Run node, a dialog looking like the following will appear.

enter image description here

Command line arguments can be set in the Arguments box as a space separated list of values. These values are received by the only argument of the main() method as an array of Strings.

So, the following program iterates through these values and displays numbers from 1 through 5.

public final class Main {

    public static void main(String[] args) {

        for (String arg : args) {
            System.out.println(arg);
        }
    }
}

These values in this case, can only statically be set and cannot be changed dynamically.

Can these values be fed dynamically to the program (probably through an IO device like the console) so that a user can supply values dynamically as we can do directly through a command-line without using an IDE?

My current environment is :

  • NetBeans 8.0.1
  • JDK 8u25
Tiny
  • 27,221
  • 105
  • 339
  • 599
  • you can probably just set up an IO method for the user and then take these as arguments as well – jgr208 Dec 10 '14 at 16:25
  • maybe this can help you [Java: How to get input from System.console()](http://stackoverflow.com/questions/4644415/java-how-to-get-input-from-system-console) – xav56883728 Dec 19 '14 at 12:10

0 Answers0