Reputation: 775
I have a problem with a batch script that runs a java program, here some key lines of the script:
exeFinder="java -client -classpath './classes:./lib/javacsv.jar' -Xmx7200m Finder.Main ";
runFinder() {
cleanFolders;
$exeFinder $1 $2 $3 > $4;
}
dbName=$1;
k=$2;
n=$3;
outFile="simple_tester-out.log";
runFinder $dbName $k $n $outFile;
I run the script with its arguments:
./myScript.sh testing_7x8.csv 7 8
And I get this:
Error: Could not find or load main class Finder.Main
It looks like a java problem, so I change the line $exeFinder $1 $2 $3 > $4;
for echo "$exeFinder $1 $2 $3 > $4";
to get my execution line:
java -client -classpath './classes:./lib/javacsv.jar' -Xmx7200m Finder.Main testing_7x8.csv 7 8 > simple_tester-out.log
And it works like a charm! So I don't know what is happening.
I have checked some questions like this and this, but I can't see anything useful for me.
Thanks for your time, guys
Upvotes: 0
Views: 80
Reputation: 775
It was a little problem with the simple quotes in the execution variable, so instead of:
"java -client -classpath './classes:./lib/javacsv.jar' -Xmx7200m Finder.Main "
it must be:
"java -client -classpath ./classes:./lib/javacsv.jar -Xmx7200m Finder.Main "
It is probably something related with bash and how it works, I don't know enough to explain why this happens, but that change solved the problem.
Upvotes: 1
Reputation: 1548
Try sh $exeFinder $1 $2 $3 > $4;
In my testing, I was unable to directly execute a command in a variable, but I could pass it to sh.
Upvotes: 0