
Java
Command line arguments are accessible in a Java program as an array of String objects passed into the program's "main" method. Unlike some programming languages (such as C/C++), where the command used to invoke the program is passed into the first array location (index 0) and the arguments subsequently, in Java the first argument occupies index 0.
Command line arguments are a useful way of gathering information from the user when it is likely will know the information at the start of the program. For example, a Java application might copy a file from myFile.txt to myNewFile.txt by running the command "Java CopyUtil myFile.txt myNewFile.txt". It is useful to allow such information to be passed in via command line arguments to make the program more scriptable: in other Words, more conducive to scripted invocation, through a Desktop shortcut, through a batch file, through a shell script, etc.
Copyright © 2026 eLLeNow.com All Rights Reserved.