简体   繁体   中英

java matlab how can I run a jar inside a matlab script?

I created a jar that basically parses a bunch of pdf/text files and creates a .mat file. I also have a matlab script that loads that .mat file and compares the data against some other data. I want to ensure that the jar runs and updates the .mat file first. I want the first line of my matlab script to execute the jar and wait for it to complete. How do I do this?

我通过使用system('java -jar jarname.jar')运行它

Make sure the jar is in your Matlab class path. Presumably there is some static method you use in the jar, so from matlab your script can just call com.mydomain.packagename.MainClass.main() . Control doesn't return to Matlab until that call is finished, and, presumably, the .mat file is created. So your next matlab line would be load('myfile.mat') . If this isn't working, can you be more specific?

Your Java api call must be blocking. Do not return from your Java parsing task until it is finished.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM