com.mathworks.runtime.ApplicationMode
Java 枚举,用于指定 MATLAB Runtime 实例创建的进程模式
自 R2026a 起
描述
ApplicationMode 枚举用于确定一个 MATLAB® Runtime 实例是在与 Java® 应用程序相同的进程中运行,还是在单独的子进程中运行。
枚举值
IN_PROCESS | 在与 Java 应用程序相同的进程中创建 MATLAB Runtime 实例。 |
OUT_OF_PROCESS | 在单独的子进程中创建 MATLAB Runtime 实例。 |
示例
public class Example {
public static void main(String[] args) {
String ctfPath = "C:/path/to/your/ctf";
// Start MATLAB Runtime in the same process
try (MatlabRuntime runtime = MatlabRuntime.startMatlab(ctfPath, ApplicationMode.IN_PROCESS)) {
// Runtime operations here
System.out.println("MATLAB Runtime started in-process");
} catch (MatlabNotAvailableException | InterruptedException |
IllegalArgumentException | IllegalStateException e) {
System.out.println("Error with in-process MATLAB Runtime: " + e.getMessage());
}
// Start MATLAB Runtime in a separate process
try (MatlabRuntime runtime = MatlabRuntime.startMatlab(ctfPath, ApplicationMode.OUT_OF_PROCESS)) {
// Runtime operations here
System.out.println("MATLAB Runtime started out-of-process");
} catch (MatlabNotAvailableException | InterruptedException |
IllegalArgumentException | IllegalStateException e) {
System.out.println("Error with out-of-process MATLAB Runtime: " + e.getMessage());
}
}
}版本历史记录
在 R2026a 中推出