The code below will process the String array that contains the command line arguments passed to the main method when Java runs.
A google search will show you how to turn on and provide command line args to your Java program in Eclipse, etc.
class MainArgs {
public static void main (String[] args) {
if (args.length==0) {
// there are no command like args
System.out.println("mode 1");
System.out.println("we will do the interactive test driver");
}
else {
// there are command line args
int pri;
String assocData;
System.out.println("mode 2");
System.out.print("here are the args: ");
int na = args.length; // our test data will make this even
for (int i=0; i < na; i+=2) {
pri = Integer.parseInt(args[i]);
assocData = args[i+1];
System.out.print(pri+":");
System.out.print(assocData+", ");
}
System.out.println();
}
}
}