External Interfaces/API Reference |
Generate an error message based on Java feature support
Syntax
Description
javachk(feature)
returns a generic error message if the specified Java feature
is not available in the current MATLAB session. If it is available, javachk
returns an empty matrix. Possible feature
arguments are shown in the following table.
Feature |
Description |
'awt' |
Abstract Window Toolkit components1 are available. |
'desktop' |
The MATLAB interactive desktop is running. |
'jvm' |
The Java Virtual Machine is running. |
'swing' |
Swing components2 are available. |
1. Java's GUI components in the Abstract Window Tookit
2. Java's lightweight GUI components in the Java Foundation Classes
javachk(feature, component)
works the same as the above syntax, except that the specified component
is also named in the error message. (See the example below.)
Examples
The following M-file displays an error with the message "CreateFrame is not supported on this platform."
when run in a MATLAB session in which the AWT's GUI components are not available. The second argument to javachk
specifies the name of the M-file, which is then included in the error message generated by MATLAB.
javamsg = javachk('awt', mfilename); if isempty(javamsg) myFrame = java.awt.Frame; myFrame.setVisible(1); else error(javamsg); end
See Also
javaArray | javaMethod |