Reputation: 287
when I try to command in command line it executes fine
$: /application/jre/bin/java -classpath /application/common/lib/apps.jar: ./updater.jar com.application.updatermain mobile
This executes perfectly fine and returns me the results whereas when I try putting this in a file called run.sh
If I create a run.sh
as
/application/jre/bin/java -classpath /application/common/lib/apps.jar: ./updater.jar com.application.updatermain $@
and try to run it
./run.sh mobile
it acts weird
My java code:
if (args.length == 1) {
if (args[0].equalsIgnoreCase("mobile") ) {
updateDB = true;
} else {
System.out.println(" 1 :Usage: ./run.sh [mobile] "+ args[0]);
return;
}
}
It gives me the output
1 :Usage: ./run.sh [mobile] mobile
Am I missing anything here.
Thanks a lot
Upvotes: 1
Views: 1692
Reputation: 1722
Remove the space before "./updater.jar";
the script "run.sh"
should contain:
/application/jre/bin/java -classpath /application/common/lib/apps.jar:./updater.jar com.application.updatermain $@
Upvotes: 1
Reputation: 5414
it seems that some space add to argument.
you must trim
the arg[0]
:
if (args.length == 1) {
if (args[0].trim().equalsIgnoreCase("mobile") ) {
updateDB = true;
}
else {
System.out.println(" 1 :Usage: ./run.sh [mobile] "+ args[0]);
return;
}
}
Upvotes: 1