javachk

Checks whether a Java feature is available and returns a message if it is not.

Category: Environment and Settings > Platform and License

Syntax

msg = javachk(feature)

Checks the feature, such as 'jvm', 'awt', 'swing' or 'desktop'.

msg = javachk(feature, component)

Uses component in the message so it names what needs the feature.

Description

javachk lets code fail gracefully before it calls into Java. The typical pattern is to test isempty(msg), and if it is not empty, show msg.message or pass the structure to error.

MatLivre does not run a Java virtual machine, so every feature check reports that Java is not available.

Input arguments

feature
Name of the Java feature to test.
component
Optional name of the code or tool that needs the feature.

Output arguments

msg
Structure with the fields message and identifier, describing why the feature is unavailable; empty when the feature is available.

Example

Ask for a Java feature

msg = javachk('awt', 'Plot');
isempty(msg)
disp(msg.message)
Output
ans = logical
   0
Plot is not supported because:
Java is not currently available.

See also

usejava error version computer