[英]How to communicate between C++ and JAVA via Memory-Mapped file without NMI?
I have a C++ COMPILED code which takes two arguments: input file & output file. 我有一个C ++ COMPILED代码,它带有两个参数:输入文件和输出文件。 It's also not possible to pipe input and output. 也无法通过管道传递输入和输出。 I want to call this program from a Java application. 我想从Java应用程序调用此程序。 The only performance-improvement option which comes to mind, is to use memory-mapped files. 想到的唯一性能改进选项是使用内存映射文件。 The task is simple: 任务很简单:
How can I do it in Java? 如何用Java做到这一点?
You can achieve that by: 您可以通过以下方法实现:
try {
//Start the c++ program
Process p = Runtime.getRuntime().exec("MyCppProgram.exe "+"intputFile "+"outputFile");
// wait until the program finishes
p.waitFor();
// Done, process output file
}
catch (Exception e) {
e.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.