FAQ: How do I pass command line arguments to a program in Eclipse?

  1. Select your project in the Package Explorer on the left side of the Java perspective

    Figure 1 - Package Explorer
  2. From the main menu, select Run > Run Configurations...

    Figure 2 - Run menu
  3. If you already have a run configuration listed for your project under Java Application in the left pane of the Run Configurations dialog, select it, and skip to the next step. Otherwise, select Java Application in the left pane, and click the New launch configuration button

    Figure 3 - New Launch Configuration
  4. Select the newly created run configuration (or your existing configuration). On the Main tab in the right pane, click the Search button beside the Main class field

    Figure 4 - Main tab
  5. In the Select Main Type dialog, select the class that you wish to run and click OK

    Figure 5 - Select Main Type dialog
  6. Select the Arguments tab. In the Program arguments field (do not mistake this for the VM arguments field), enter any arguments that you wish to pass to your program

    Figure 6 - Program arguments
  7. When finished, click Apply and then Run to execute your program. Each time you wish to execute your program afterward, you can simply press the Run toolbar button in the Java perspective to run your program — you do not need to run your program from the Run Configurations dialog each time. Furthermore, note that to modify the arguments passed to your program, you will need to edit your run configuration by selecting Run > Run Configurations from the main menu