Reputation: 1
If I have a .jar
file that takes two command line arguments. How can I call it from a Matlab .m
file?
I can call the jar file from the command line like this:
jar -jar art.jar ex.xls 0
Upvotes: 0
Views: 2732
Reputation: 451
You can use system() function. e.g.:
[status result] = system('java -jar art.jar ex.xls 0');
If you need to pass variables as parameters, you have to convert them to strings and then concatenate them (with space as separator). e.g.:
jarfile = 'art.jar';
xlsfile = 'ex.xls';
n = 0;
commandtext = ['java -jar ' jarfile ' ' xlsfile ' ' num2str(n)];
system(commandtext);
Upvotes: 6