Dynamically Specify Options to MATLAB Runtime
What Options Can You Specify?
You can pass MATLAB® Runtime options -nojvm
, -nodisplay
, and
-logfile
to MATLAB
Compiler SDK™ from the client application using two classes in
javabuilder.jar
:
MWApplication
MWMCROption
Set and Retrieve MATLAB Runtime Option Values Using MWApplication
The MWApplication
class provides several static methods to set
MATLAB Runtime option values and also to retrieve them. The following table lists static
methods supported by this class.
MWApplication Static Methods | Purpose |
---|---|
MWApplication.initialize(MWMCROption...
| Passes MATLAB Runtime run-time options (see Specifying Run-Time Options Using MWMCROption) |
MWApplication.isMCRInitialized(); | Returns true if MATLAB Runtime is initialized; otherwise returns false
|
MWApplication.isMCRJVMEnabled(); | Returns true if MATLAB Runtime is launched with JVM; otherwise returns
false
|
MWApplication.isMCRNoDisplaySet();
| Returns Note
|
MWApplication.getMCRLogfileName(); | Retrieves the name of the log file |
Specifying Run-Time Options Using MWMCROption
MWApplication.initialize
takes zero or more
MWMCROption
s.
Calling MWApplication.initialize()
without any inputs launches
MATLAB Runtime with the following default values.
You must call MWApplication.initialize()
before performing any
other processing.
These options are all write-once, read-only properties.
MATLAB Runtime Run-Time Option | Default Values |
---|---|
-nojvm | false |
-logfile | null |
-nodisplay | false |
-softwareopengl | false |
Note
If there are no MATLAB Runtime options being passed, you do not need to use
MWApplication.initialize
since initializing a generated
class initializes MATLAB Runtime with default options.
Use the following static members of MWMCROption
to represent
the MATLAB Runtime options you want to modify.
MWMCROption Static Members | Purpose |
---|---|
MWMCROption.NOJVM | Launches MATLAB Runtime without 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 the MATLAB Runtime should attach itself to the JVM launched by the client application. |
MWMCROption.NODISPLAY | Launches MATLAB Runtime without display functionality. |
MWMCROption.logFile(" | Allows you to specify a log file name (must be passed with a log file name). |
Pass and Retrieve MATLAB Runtime Option Values from Java Application. Following is an example of how MATLAB Runtime option 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();