Dynamically Specify Options toMATLABRuntime
What Options Can You Specify?
You can passMATLAB®Runtimeoptions-nojvm
,-nodisplay
, and-logfile
toMATLAB Compiler SDK™from the client application using two classes injavabuilder.jar
:
MWApplication
MWMCROption
Sett and RetrieveMATLABRuntimeOption Values Using MWApplication
TheMWApplication
class provides several static methods to setMATLAB Runtimeoption values and also to retrieve them. The following table lists static methods supported by this class.
MWApplication Static Methods | Purpose |
---|---|
MWApplication.initialize(MWMCROption... |
PassesMATLAB Runtimerun-time options (seeSpecifying Run-Time Options Using MWMCROption) |
MWApplication.isMCRInitialized(); |
Returnstrue ifMATLAB Runtimeis initialized; otherwise returnsfalse |
MWApplication.isMCRJVMEnabled(); |
Returnstrue ifMATLAB Runtimeis launched with JVM; otherwise returnsfalse |
MWApplication.isMCRNoDisplaySet(); |
Returns Note
|
MWApplication.getMCRLogfileName(); |
Retrieves the name of the log file |
Specifying Run-Time Options Using MWMCROption
MWApplication.initialize
takes zero or moreMWMCROption
s.
CallingMWApplication.initialize()
without any inputs launchesMATLAB Runtimewith the following default values.
You must callMWApplication.initialize()
before performing any other processing.
These options are all write-once, read-only properties.
MATLAB RuntimeRun-Time Option | Default Values |
---|---|
-nojvm |
false |
-logfile |
null |
-nodisplay |
false |
Note
If there are noMATLAB Runtime选项是不sed, you do not need to useMWApplication.initialize
since initializing a generated class initializesMATLAB Runtimewith default options.
Use the following static members ofMWMCROption
to represent theMATLAB Runtimeoptions you want to modify.
MWMCROption Static Members | Purpose |
---|---|
MWMCROption.NOJVM |
LaunchesMATLAB Runtimewithout a JVM™. When this option is used, the JVM launched by the client application is unaffected. The value of this option determines whether or not theMATLAB Runtimeshould attach itself to the JVM launched by the client application. |
MWMCROption.NODISPLAY |
LaunchesMATLAB Runtimewithout display functionality. |
MWMCROption.logFile(" |
Allows you to specify a log file name (must be passed with a log file name). |
Pass and RetrieveMATLABRuntimeOption Values fromJavaApplication.Following is an example of howMATLAB Runtimeoption values are passed and retrieved from a client-side Java®application:
MWApplication.initialize(MWMCROption.NOJVM, MWMCROption.logFile("logfile.dat"),MWMCROption.NODISPLAY); System.out.println(MWApplication.getMCRLogfileName()); System.out.println(MWApplication.isMCRInitialized()); System.out.println(MWApplication.isMCRJVMEnabled()); System.out.println(MWApplication.isMCRNoDisplaySet()); //UNIX myclass cls = new myclass(); cls.hello();