MATLAB Help Center
Error message based on Java feature support
MSG = javachk(feature)
javachk(feature,component)
MSG = javachk(feature) returns a generic error message if the specified Java® feature is not available in the current MATLAB® session.
MSG
feature
example
javachk(feature,component) also names the specified component in the error message.
component
collapse all
To test if Java is available before calling a Java command, use these statements. The isempty function is true when there is no error.
isempty
if isempty(javachk("jvm")) scalar = java.lang.Double(5); end
"awt"
"desktop"
"jvm"
"swing"
Java feature, specified as one of these values.
UI components in the Java Abstract Window Toolkit (AWT) are available. To be removed.
MATLAB interactive desktop is running. To be removed.
Java Virtual Machine software (JVM®) is available.
Swing components (Java lightweight UI components in the Java Foundation Classes) are available. To be removed.
Identifier, specified as a string or a character vector, to display in the error message.
Error message, returned as a structure with the following fields. If the feature is available, javachk returns an error structure with empty fields.
javachk
message
Message, specified as a character vector.
identifier
Identifier, specified as a character vector.
expand all
The "awt" and "swing" options for the feature argument will be removed in a future release.
To detect Java:
usejava("jvm")
To detect the desktop:
desktop("inuse")
The "desktop" option for the feature argument will be removed in a future release.
usejava | error
usejava
error
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office