Differences between OS & macros

Hi,
I’ve got a basic question. I’ve written a beanshell script which reads files from a folder, crops them, then applies a trainable weka segmentation classifier and saves the result. It contains two for-loops. The script worked fine on two windows machines, but I’ve tried to run it on linux where imageJ gets called from the console, and there both for loops proceed out of order and the ouput images are not probability maps but results.
Do I have to change the autorun settings in some way…? And why would that effect the order of the for loops. Could it be that the script isn’t run in beanshell but in some other language by accident?