Error message based on Java feature support
MSG = javachk(feature)
The following statements test if Java is
available before calling a Java command. The
is true when there is no error.
if isempty(javachk('jvm')) scalar = java.lang.Double(5); end
To provide context in the
message, add the optional text parameter to the
Create a script,
myFile.m, with the following statements. The script checks if Java is
available before calling Java to create a frame.
error(javachk('awt','myFile')) myFrame = java.awt.Frame; myFrame.setVisible(1)
Start MATLAB from the Linux® system prompt.
Run the script.
If Java is
not available, MATLAB displays
this error, identifying
the source as the
Error using myFile (line 1) myFile is not supported because: Java is not currently available.
feature— Java feature
Java feature, specified as one of these values:
UI components in the Java Abstract Window Toolkit (AWT) are available.
MATLAB interactive desktop is running.
Java Virtual Machine software (JVM™) is running.
Swing components (Java lightweight UI components in the Java Foundation Classes) are available.
Identifier, specified as a character vector, to display in the error message.
MSG— Error message
Error message, returned as a structure with the following fields.
If the feature is available,
an error structure with empty fields.
Message, specified as a character vector.
Identifier, specified as a character vector.