1 ## Copyright (C) 2012 Rik Wehbring
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} usejava (@var{feature})
21 ## Return true if the specific Sun Java element @var{feature} is available.
23 ## Possible features are:
27 ## Abstract Window Toolkit for GUIs.
30 ## Interactive desktop is running.
33 ## Java Virtual Machine.
36 ## Swing components for lightweight GUIs.
39 ## This function is provided for compatibility with @sc{matlab} scripts which
40 ## may alter their behavior based on the availability of Java. Octave does
41 ## not implement an interface to Java and this function always returns
45 function retval = usejava (feature)
47 if (nargin != 1 || ! ischar (feature))
51 if (! any (strcmp (feature, {"awt", "desktop", "jvm", "swing"})))
52 error ("usejava: unrecognized feature '%s'", feature);
60 %!assert (usejava ("awt"), false)
62 %% Test input validation
64 %!error usejava (1, 2)
66 %!error <unrecognized feature> usejava ("abc")