I am unable to call my java program from the command line. I keep getting this message:
"InitArray is not recognized as an internal or external command, operable program or batch file."
I can read the directory with the 'dir' command and see the program that I am trying to launch but cannot get past this error message!
Here is what I see: C:\Users\myName\Java_WorkSpace> And then I enter: InitArray 5 0 4
Again, I can see this program in the directory but I cannot access it. WHAT AM I DOING WRONG???
Here is the program code:
public class InitArray
{
public static void main(String[] args)
{
// check number of command-line arguments
if ( args.length != 3)
System.out.println(
"Error: Please re-enter the entire command, including\n" +
"an array size, initial value and increment.");
else
{
int arrayLength = Integer.parseInt(args[0]);
int[] array = new int[arrayLength];
int initialValue = Integer.parseInt(args[1]);
int increment = Integer.parseInt(args[2]);
// calculate value for each array element
for ( int counter = 0; counter < array.length; counter++ )
array[counter] = initialValue + increment * counter;
System.out.printf("%s%8s\n", "Index", "Value");
// display array index and value
for ( int counter = 0; counter < array.length; counter++ )
System.out.printf("%5d%8d\n", counter, array[counter]);
} // end else
} // end main
} // end class InitArray