Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

usejava

Determine if Java feature is available

Syntax

Description

example

tf = usejava(feature) returns logical 1 (true) if the specified feature is supported. Otherwise, it returns logical 0 (false). If the Java® feature is unavailable, then you can use this function for error handling.

Examples

collapse all

Use the following code snippet to test that the AWT GUI components are available before attempting to display a Java Frame. If the AWT is not available on your system, MATLAB® displays the message Unable to open a Java Frame.

if usejava('awt')
   myFrame = java.awt.Frame;
else
   disp('Unable to open a Java Frame')
end

Use the following code snippet to terminate a script if MATLAB does not have access to JVM™ software.

The variable, filename, is a function that contains Java code.

if ~usejava('jvm')
   error([filename ' requires Java to run.'])
end

Input Arguments

collapse all

Java feature, specified as one of these values:

'awt'

UI components in the Java Abstract Window Toolkit (AWT) are available.

'desktop'

MATLAB interactive desktop is running.

'jvm'

Java Virtual Machine software (JVM) is running.

'swing'

Swing components (Java lightweight UI components in the Java Foundation Classes) are available.

See Also

|

Introduced before R2006a

Was this topic helpful?