time | Calls | line |
---|
| | 1 | function isok = usejava(feature)
|
| | 2 | %USEJAVA True if the specified Java feature is supported in MATLAB.
|
| | 3 | % USEJAVA(LEVEL) returns 1 if the feature is supported and
|
| | 4 | % 0 otherwise.
|
| | 5 | %
|
| | 6 | % The following levels of support exist:
|
| | 7 | %
|
| | 8 | % LEVEL MEANING
|
| | 9 | % -----------------------------------------------------
|
| | 10 | % 'jvm' The Java Virtual Machine is running.
|
| | 11 | % 'awt' AWT components are available.
|
| | 12 | % 'swing' Swing components are available.
|
| | 13 | % 'desktop' The MATLAB interactive desktop is running.
|
| | 14 | %
|
| | 15 | % "AWT components" refers to Java's GUI components in the Abstract
|
| | 16 | % Window Toolkit. "Swing components" refers to Java's lightweight
|
| | 17 | % GUI components in the Java Foundation Classes.
|
| | 18 | %
|
| | 19 | % EXAMPLES:
|
| | 20 | %
|
| | 21 | % If you want to write a MATLAB program that displays a Java Frame and want
|
| | 22 | % to be robust to the case when there is no display set or no JVM
|
| | 23 | % available, you can do the following:
|
| | 24 | %
|
| | 25 | % if usejava('awt')
|
| | 26 | % myFrame = java.awt.Frame;
|
| | 27 | % else
|
| | 28 | % disp('Unable to open a Java Frame.');
|
| | 29 | % end
|
| | 30 | %
|
| | 31 | % If you want to write a MATLAB program that uses Java code and want it to
|
| | 32 | % fail gracefully when run in a MATLAB session that does not have access
|
| | 33 | % to a JVM, you can add the following check:
|
| | 34 | %
|
| | 35 | % if ~usejava('jvm')
|
| | 36 | % error([mfilename ' requires Java to run.']);
|
| | 37 | % end
|
| | 38 | %
|
| | 39 | % See also JAVACHK
|
| | 40 |
|
| | 41 | % Copyright 1984-2011 The MathWorks, Inc.
|
| | 42 |
|
< 0.001 | 24 | 43 | narginchk(1,1);
|
< 0.001 | 24 | 44 | isok = system_dependent('useJava',feature);
|
Other subfunctions in this file are not included in this listing.