Skip to Main Content Skip to Search
Product Documentation

usejava - Determine whether Sun Java feature is supported in MATLAB software

Syntax

usejava(feature)

Description

usejava(feature) returns 1 if the specified feature is supported and 0 otherwise.

The following table shows the valid feature arguments.

Feature

Description

'awt'

Java GUI components in the Abstract Window Toolkit components are available.

'desktop'

The MATLAB interactive desktop is running.

'jvm'

The Java Virtual Machine software (JVM) is running.

'swing'

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

Examples

The following conditional code ensures that the AWT GUI components are available before the script attempts to display a Java Frame.

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

The next example is part of a script that includes Java code. It fails gracefully when run in a MATLAB session that does not have access to JVM software.

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

See Also

javachk

  


» Learn more
» Download free kit
» Get trial software

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