FAQ: How do I pass command line arguments to a program in Eclipse?
- Select your project in the Package Explorer on the left side of the Java perspective
- From the main menu, select Run > Run Configurations...
- 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
- 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
- In the Select Main Type dialog, select the class that you wish to run and click OK
- 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
- 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