0% found this document useful (0 votes)
56 views

Command Line ARguments in Eclipse

To specify command line arguments in Eclipse, go to Run > Run..., select the correct project and arguments tab, enter arguments separated by spaces. The code can then reference the String[] args array to access the arguments, storing values from args into own arrays and variables that can be used in the program.

Uploaded by

Saira Anwar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Command Line ARguments in Eclipse

To specify command line arguments in Eclipse, go to Run > Run..., select the correct project and arguments tab, enter arguments separated by spaces. The code can then reference the String[] args array to access the arguments, storing values from args into own arrays and variables that can be used in the program.

Uploaded by

Saira Anwar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

To specify command line arguments in eclipse, go to Run -> Run…

Make sure you are running the correct project for which you want to specify
command line arguments for, and then select the arguments tab.
Now enter the arguments you want, separated by spaces.
Now use the arguments in your code by referencing the String[] args array
from the parameter list shown here on line 3.

In this example, we specified a combination of numbers and a filename (see


above). Now we store those values from args into our own array.

Since the filename is the last thing specified, we take it from the last position
in the array. Then we use a loop to store each of the numbers into an int
array, being careful to convert from string to int.

Finally we print out the contents of the variables we just initialized.


Here is the output from the code above using the command line arguments
specified above.

You might also like