HOW TO PASS COMMAND-LINE ARGUMENTS IN ECLIPSE IDE?
Posted by Hemprasad Y. Badgujar on November 30, 2015
New Java Project
- Create a new Java Project and name it as “CommandLineArguments“
Right click on Package Explorer -> New -> Project -> Select Java Project
- Create a new Package and name it as “commandline“
Right click on src -> New -> Package
- Create a new Java Class and name it as “AdditionOfTwoNumbers” in the package “commandline“. Make sure you select main method option.
Right click on commandline package -> New -> Class
Paste this code in the main method.
Save the program.
- Press [Ctrl + s] to save your program
Go to Run menu and select Run Configurations. Run Configurations dialogue box opens.
Run your program
- Select your Java class from the left side column. If you do not find your class, then click on the “New launch Configuration” button, found above the class list.
- In the right side menu select “Arguments” tab
- In the “Program Arguments” text area type the input numbers separated by spaces or newline.
- Click Run button.
- You will see the output in the console.
The Sum is: 32