0

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.

0

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.