Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

javachk - Generate error message based on Sun Java feature support

Syntax

javachk(feature)
javachk(feature, component)

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 software(JVM™) is running.

'swing'

Swing components2 are available.

1. Java GUI components in the Abstract Window Toolkit

2. Java 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

usejava

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS