I tried to collect some information about the system such as memory usage and cpu usage and pass it to a java application which is responsible to store it into a database.
1 Answer
Well you are on the right path on calling the java program with at the end of your bash script.
I am 99.9% sure you need to call java -jar not just java in your bash script.
java Program $perName $systemCpuUsage $systemMemoryUsage $readingTime
java -jar Program $perName $systemCpuUsage $systemMemoryUsage $readingTime
Also in your main java class I think your should call a for each statement instead of a fixed loop.
for(String arg : args)
{
System.out.println(arg);
}
And the only other thing I can think of is that there is something wrong with your bash script is not getting the variables correctly. You should try to echo out your results to debug what the variables are supposed to be in the bash script.
EDIT
ArrayIndexOutOfBoundsException means that your looping two many times. Replacing it with a for each will tell you how many variables were passed through. When you get that error it means that your args array is not big enough and your trying to get data from a section in your array that doesn't exists.