This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Error message based on Java feature support




MSG = javachk(feature) returns a generic error message if the specified Java® feature is not available in the current MATLAB® session.


javachk(feature,component) also names the specified component in the error message.


collapse all

Generate Error

if isempty(javachk('jvm'))
   scalar = java.lang.Double(5);
% Check that JVM is available & JavaFigures are supported

Generate Error in User-Defined Script

If you write a script, myFile, that displays a Java Frame and want it to error gracefully if a frame cannot be displayed, do the following:

myFrame = java.awt.Frame;

If the script cannot display a frame, it displays this error:

myFile is not supported on this platform.

Input Arguments

collapse all

feature — Java feature'awt' | 'desktop' | 'jvm' | 'swing'

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.

component — Identifiercharacter vector

Identifier, specified as a character vector, to display in the error message.

Data Types: char

Output Arguments

collapse all

MSG — Error messagestructure

Error message, returned as a structure with these fields:

If it is available, javachk returns an error structure with empty message and identifier fields.

message — Messagecharacter vector | empty

Message, specified as a character vector.

identifier — Identifiercharacter vector | empty

Identifier, specified as a character vector.

See Also


Introduced before R2006a

Was this topic helpful?