]> Creatis software - CreaPhase.git/blob - octave_packages/io-1.0.19/chk_spreadsheet_support.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / io-1.0.19 / chk_spreadsheet_support.m
1 % Check Octave / Matlab environment for spreadsheet I/O support.
2 %
3 %   usage:  [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] [,PATH_TO_OOO])
4 %
5 % CHK_SPREADSHEET_SUPPORT first checks ActiveX (native MS-Excel); then
6 % Java JRE presence, then Java support (builtin/activated (Matlab) or
7 % added tru octave-forge Java package (Octave); then check existing
8 % javaclasspath for Java class libraries (.jar) needed for various
9 % Java-based spreadsheet I/O interfaces.
10 % If desired the relevant classes can be added to the dynamic
11 % javaclasspath. In that case the path name to the directory 
12 % containing these classes should be specified as input argument
13 % with -TAKE NOTICE- /forward/ slashes. In these jars reside in
14 % different directories, multiple calls to chk_spreadsheet_support
15 % can be made.
16 %
17 %     Input arguments (all are optional, but the order is important):
18 % /PATH/TO/JARS = (string) path (relative or absolute) to a
19 %                 subdirectory where java class libraries (.jar)
20 %                 for spreadsheet I/O reside. Can be [] or ''
21 % DEBUG_LEVEL   = (integer) between [0 (no output) .. 3 (full output]
22 % PATH_TO_OOO   = (string) installation directory of Openffice.org,
23 %                 usually (but not guaranteed):
24 %                 - Windows: C:\Program Files\OpenOffice.org
25 %                 - *nix:    /usr/lib/ooo
26 %                 - Mac OSX: ?????
27 %                 IMPORTANT: PATH_TO_OOO should be such that both:
28 %                 1. PATH_TO_OOO/program/       
29 %                  and
30 %                 2. PATH_TO_OOO/ure/.../ridl.jar
31 %                 resolve OK
32 %     Returns:
33 % RETVAL        =  0 No spreadsheet I/O support found
34 %               <> 0 At least one spreadsheet I/O interface found. RETVAL
35 %                  RETVAL will be set to the sum of values for found interfaces:
36 %                  ---------- XLS (Excel) interfaces: ----------
37 %                    1 = COM (ActiveX / Excel)
38 %                    2 = POI (Java / Apache POI)
39 %                    4 = POI+OOXML (Java / Apache POI)
40 %                    8 = JXL (Java / JExcelAPI)
41 %                   16 = OXS (Java / OpenXLS)
42 %                  --- ODS (OpenOffice.org Calc) interfaces ----
43 %                   32 = OTK (Java/ ODF Toolkit)
44 %                   64 = JOD (Java / jOpenDocument)
45 %                  ----------------- XLS & ODS: ----------------
46 %                  128 = UNO (Java / UNO bridge - OpenOffice.org)
47
48 function  [ retval ]  = chk_spreadsheet_support (path_to_jars, dbug, path_to_ooo)
49
50 % Copyright (C) 2009,2010,2011 Philip Nienhuis <prnienhuis at users.sf.net>
51 %
52 % This program is free software; you can redistribute it and/or modify it under
53 % the terms of the GNU General Public License as published by the Free Software
54 % Foundation; either version 3 of the License, or (at your option) any later
55 % version.
56 %
57 % This program is distributed in the hope that it will be useful, but WITHOUT
58 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59 % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
60 % details.
61 %
62 % You should have received a copy of the GNU General Public License along with
63 % this program; if not, see <http://www.gnu.org/licenses/>.
64
65
66 % Author: Philip Nienhuis
67 % Created 2010-11-03 for Octave & Matlab
68 % Updates:
69 % 2010-12-19 Found that dom4j-1.6.1.jar is needed regardless of ML's dom4j
70 %            presence in static classpath (ML r2007a)
71 % 2011-01-04 Adapted for general checks, debugging & set up, both Octave & ML
72 % 2011-04-04 Rebuilt into general setup/debug tool for spreadsheet I/O support
73 %            and renamed chk_spreadsheet_support()
74 % 2011-05-04 Added in UNO support (OpenOffice.org & clones)
75 %     ''     Improved finding jar names in javaclasspath
76 % 2011-05-07 Improved help text
77 % 2011-05-15 Better error msg if OOo instal dir isn't found
78 % 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_)
79 % 2011-05-27 Fix proper return value (retval); header text improved
80 % 2011-05-29 Made retval value dependent on detected interfaces & adapted help text
81 % 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg
82 %     ''     Fixed wrong return value update when adding UNO classes
83 % 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar
84 % 2011-09-18 Fixed 'Matlab style short circuit' warning in L. 152
85 % 2012-12-24 Amended code stanze to find unoil.jar; now works in LibreOffice 3.5b2 as well
86 % 2012-06-07 Replaced all tabs by double space
87
88   jcp = []; retval = 0;
89   if (nargin < 3); path_to_ooo= ''; end %if
90     if (nargin < 2); dbug = 0; end %if
91   isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0;
92     if (dbug); fprintf ('\n'); end %if
93   % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order  = vital
94
95   % Check if MS-Excel COM ActiveX server runs
96   if (dbug), fprintf ('Checking Excel/ActiveX/COM... '); end %if
97   try
98     app = actxserver ('Excel.application');
99     % If we get here, the call succeeded & COM works.
100     xlsinterfaces.COM = 1;
101     % Close Excel to avoid zombie Excel invocation
102     app.Quit();
103     delete(app);
104     if (dbug), fprintf ('OK.\n\n'); end %if
105     retval = retval + 1;
106   catch
107     % COM not supported
108     if (dbug), fprintf ('not working.\n\n'); end %if
109     end %try_catch
110
111     % Check Java
112   if (dbug), fprintf ('Checking Java support...\n'); end %if
113   if (dbug > 1), fprintf ('  1. Checking Java JRE presence.... '); end %if
114   % Try if Java is installed at all
115   if (isOctave)
116     if (ispc)
117       jtst = (system ('java -version 2> nul'));
118     else
119       jtst = (system ('java -version 2> /dev/null'));
120     end %if
121   else
122     tst1 = version ('-java');
123         jtst = isempty (strfind (tst1, 'Java'));
124   end %if
125   if (jtst)
126     error ('Apparently no Java JRE installed.');
127   else
128     if (dbug > 1), fprintf ('OK, found one.\n'); end %if
129   end %if
130   if (dbug > 1 && isOctave), fprintf ('  2. Checking Octave Java support... '); end %if
131   try
132     jcp = javaclasspath ('-all');            % For Octave java pkg > 1.2.7
133     if (isempty (jcp)), jcp = javaclasspath; end %if  % For Octave java pkg < 1.2.8
134     % If we get here, at least Java works.
135     if (dbug > 1 && isOctave), fprintf ('Java package seems to work OK.\n'); end %if
136     % Now check for proper version (> 1.6.x.x)
137     jver = char (javaMethod ('getProperty', 'java.lang.System', 'java.version'));
138     cjver = strsplit (jver, '.');
139     if (sscanf (cjver{2}, '%d') < 6)
140       if (dbug)
141         fprintf ('  Java version (%s) too old - you need at least Java 6 (v. 1.6.x.x)\n', jver);
142         if (isOctave)
143           warning ('    At Octave prompt, try "!system ("java -version")"'); 
144         else
145           warning ('    At Matlab prompt, try "version -java"');
146         end %if
147       end %if
148       return
149     else
150       if (dbug > 2), fprintf ('  Java (version %s) seems OK.\n', jver); end %if
151     end %if
152     % Under *nix the classpath must first be split up.
153     % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit()
154     % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order
155      if (isunix && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if
156     if (dbug > 1)
157       % Check JVM virtual memory settings
158       jrt = javaMethod ('getRuntime', 'java.lang.Runtime');
159       jmem = jrt.maxMemory ();
160             if (isOctave), jmem = jmem.doubleValue(); end %if
161       jmem = int16 (jmem/1024/1024);
162       fprintf ('  Maximum JVM memory: %5d MiB; ', jmem);
163       if (jmem < 400)
164         fprintf ('should better be at least 400 MB!\n');
165         fprintf ('    Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n');
166         if (isOctave)
167           fprintf ('    %s\n', [matlabroot filesep 'share' filesep 'octave' filesep 'packages' filesep 'java-<version>' filesep 'java.opts']);
168         else
169           fprintf ('    $matlabroot/bin/<arch>]\n');
170         end %if
171       else
172         fprintf ('sufficient.\n');
173       end %if
174     end %if
175     if (dbug), fprintf ('Java support OK\n'); end %if
176     catch
177     error ('No Java support found: %s.', lasterr);
178   end %try_catch
179
180   if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if
181
182   % Try Java & Apache POI. First Check basic .xls (BIFF8) support
183   if (dbug > 1), fprintf ('\nBasic POI (.xls) <poi-3> <poi-ooxml>:\n'); end %if
184   jpchk1 = 0; entries1 = {'poi-3', 'poi-ooxml-3'}; missing1 = zeros (1, numel (entries1));
185   % Only under *nix we might use brute force: e.g., strfind (javaclasspath, classname)
186   % as javaclasspath is one long string. Under Windows however classpath is a cell array
187   % so we need the following more subtle, platform-independent approach:
188   for jj=1:length (entries1)
189     found = 0;
190     for ii=1:length (jcp)
191       jcplst = strsplit (jcp{ii}, filesep);
192       jcpentry = jcplst {end};
193       if (~isempty (strfind (lower (jcpentry), lower (entries1{jj}))))
194         jpchk1 = jpchk1 + 1; found = 1;
195         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
196       end %if
197     end %for
198     if (~found)
199       if (dbug > 2), fprintf ('  %s....jar missing\n', entries1{jj}); end %if 
200       missing1(jj) = 1; 
201     end %if
202   end %for
203   if (jpchk1 >= numel (entries1)), retval = retval + 2; end %if
204   if (dbug > 1)
205     if (jpchk1 >= numel (entries1))
206       fprintf ('  => Apache (POI) OK\n');
207     else
208       fprintf ('  => Not all classes (.jar) required for POI in classpath\n');
209     end %if
210   end %if
211   % Next, check OOXML support
212     if (dbug > 1), fprintf ('\nPOI OOXML (.xlsx) <xbean> <poi-ooxml-schemas> <dom4j>:\n'); end %if
213   jpchk2 = 0; entries2 = {'xbean', 'poi-ooxml-schemas', 'dom4j-1.6.1'}; 
214   missing2 = zeros (1, numel (entries2));
215   for jj=1:length (entries2)
216     found = 0;
217     for ii=1:length (jcp)
218       jcplst = strsplit (jcp{ii}, filesep);
219       jcpentry = jcplst {end};
220       if (~isempty (strfind (lower (jcpentry), lower (entries2{jj}))))
221         jpchk2 = jpchk2 + 1; found = 1;
222         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
223       end %if
224     end % for
225     if (~found)
226       if (dbug > 2), fprintf ('  %s....jar missing\n', entries2{jj}); end %if
227       missing2(jj) = 1;
228     end %if
229   end % for
230   % Only update retval if all classes for basic POI have been found in javaclasspath
231   if (jpchk1 >= numel (entries1) && jpchk2 >= numel (entries2)), retval = retval + 4; end %if
232   if (dbug > 1)
233     if (jpchk2 >= numel (entries2)) 
234       fprintf ('  => POI OOXML OK\n');
235     else
236       fprintf ('  => Some classes for POI OOXML support missing\n'); 
237     end %if
238   end %if
239
240   % Try Java & JExcelAPI
241   if (dbug > 1), fprintf ('\nJExcelAPI (.xls (incl. BIFF5 read)) <jxl>:\n'); end %if
242   jpchk = 0; entries3 = {'jxl'}; missing3 = zeros (1, numel (entries3));
243   for jj=1:length (entries3)
244     found = 0;
245     for ii=1:length (jcp)
246       jcplst = strsplit (jcp{ii}, filesep);
247       jcpentry = jcplst {end};
248       if (~isempty (strfind (lower (jcpentry), lower (entries3{jj}))))
249         jpchk = jpchk + 1; found = 1;
250         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
251       end % if
252     end %for
253     if (~found) 
254       if (dbug > 2), fprintf ('  %s....jar missing\n', entries3{jj}); end %if 
255       missing3(jj) = 1; 
256     end %if
257   end %for
258   if (jpchk >= numel (entries3)), retval = retval + 8; end %if
259   if (dbug > 1)
260     if (jpchk >= numel (entries3))
261       fprintf ('  => Java/JExcelAPI (JXL) OK.\n');
262     else
263       fprintf ('  => Not all classes (.jar) required for JXL in classpath\n');
264     end %if
265   end %if
266
267   % Try Java & OpenXLS
268   if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if
269   jpchk = 0; entries4 = {'OpenXLS'}; missing4 = zeros (1, numel (entries4));
270   for jj=1:length (entries4)
271     found = 0;
272     for ii=1:length (jcp)
273       jcplst = strsplit (jcp{ii}, filesep);
274       jcpentry = jcplst {end};
275       if (~isempty (strfind (lower (jcpentry), lower (entries4{jj}))))
276         jpchk = jpchk + 1; found = 1;
277         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
278       end % if
279     end %for
280     if (~found) 
281       if (dbug > 2), fprintf ('  %s....jar missing\n', entries4{jj}); end %if 
282       missing4(jj) = 1; 
283     end %if
284   end %for
285   if (jpchk >= numel (entries4)), retval = retval + 16; end %if
286   if (dbug > 1)
287     if (jpchk >= numel (entries4))
288       fprintf ('  => Java/OpenXLS (OXS) OK.\n');
289     else
290       fprintf ('  => Not all classes (.jar) required for OXS in classpath\n');
291     end %if
292   end %if
293
294   % Try Java & ODF toolkit
295   if (dbug > 1), fprintf ('\nODF Toolkit (.ods) <odfdom> <xercesImpl>:\n'); end %if
296   jpchk = 0; entries5 = {'odfdom', 'xercesImpl'}; missing5 = zeros (1, numel (entries5));
297   for jj=1:length (entries5)
298     found = 0;
299     for ii=1:length (jcp)
300       jcplst = strsplit (jcp{ii}, filesep);
301       jcpentry = jcplst {end};
302       if (~isempty (strfind ( lower (jcpentry), lower (entries5{jj}))))
303         jpchk = jpchk + 1; found = 1;
304         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
305       end %if
306     end %for
307     if (~found) 
308       if (dbug > 2), fprintf ('  %s....jar missing\n', entries5{jj}); end %if
309       missing5(jj) = 1; 
310     end %if
311   end %for
312   if (jpchk >= numel (entries5))    % Apparently all requested classes present.
313     % Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6 work OK).
314     % The odfdom team deemed it necessary to change the version call so we need this:
315     odfvsn = ' ';
316     try
317       % New in 0.8.6
318       odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest');
319     catch
320       % Worked in 0.7.5
321       odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version');
322     end %try_catch
323     if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7'))
324       warning ('  *** odfdom version (%s) is not supported - use v. 0.8.6 or 0.8.7.\n', odfvsn);
325     else  
326       if (dbug > 1), fprintf ('  => ODFtoolkit (OTK) OK.\n'); end %if
327       retval = retval + 32;
328     end %if
329     elseif (dbug > 1)
330     fprintf ('  => Not all required classes (.jar) in classpath for OTK\n');
331   end %if
332
333   % Try Java & jOpenDocument
334   if (dbug > 1), fprintf ('\njOpenDocument (.ods + experimental .sxc readonly) <jOpendocument>:\n'); end %if
335   jpchk = 0; entries6 = {'jOpenDocument'}; missing6 = zeros (1, numel (entries6));
336   for jj=1:length (entries6)
337     found = 0;
338     for ii=1:length (jcp)
339       jcplst = strsplit (jcp{ii}, filesep);
340       jcpentry = jcplst {end};
341        if (~isempty (strfind (lower (jcpentry), lower (entries6{jj}))))
342         jpchk = jpchk + 1; found = 1;
343         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
344       end %if
345     end %for
346     if (~found) 
347       if (dbug > 2), fprintf ('  %s....jar missing\n', entries6{jj}); end %if 
348       missing6(jj) = 1; 
349     end %if
350   end %for
351   if (jpchk >= numel (entries6)), retval = retval + 64; end %if
352   if (dbug > 1)
353     if (jpchk >= numel(entries6))
354       fprintf ('  => jOpenDocument (JOD) OK.\n');
355     else
356       fprintf ('  => Not all required classes (.jar) in classpath for JOD\n');
357     end %if
358   end %if
359
360   % Try Java & UNO
361   if (dbug > 1), fprintf ('\nUNO/Java (.ods, .xls, .xlsx, .sxc) <OpenOffice.org>:\n'); end %if
362   % entries0(1) = not a jar but a directory (<000_install_dir/program/>)
363   jpchk = 0; entries0 = {'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'};
364   missing0 = zeros (1, numel (entries0));
365   for jj=1:numel (entries0)
366     found = 0;
367     for ii=1:numel (jcp)
368       jcplst = strsplit (jcp{ii}, filesep);
369       jcpentry = jcplst {end};
370       if (~isempty (strfind (lower (jcpentry), lower (entries0{jj}))))
371         jpchk = jpchk + 1; found = 1;
372         if (dbug > 2), fprintf ('  - %s OK\n', jcp{ii}); end %if
373       end %if
374     end %for
375     if (~found)
376       if (dbug > 2)
377         if (jj == 1)
378           % Just a dir
379           fprintf ('  %s.... (directory) not found\n', entries0{jj}); 
380         else
381           fprintf ('  %s....jar missing\n', entries0{jj}); 
382         end %if
383       end %if 
384       missing0(jj) = 1; 
385     end %if
386   end %for
387   if (jpchk >= numel (entries0)), retval = retval + 128; end %if
388   if (dbug > 1)
389     if (jpchk >= numel (entries0))
390       fprintf ('  => UNO (OOo) OK\n');
391     else
392       fprintf ('  => One or more UNO classes (.jar) missing in javaclasspath\n');
393     end %if
394   end %if
395
396   % If requested, try to add UNO stuff to javaclasspath
397   ujars_complete = isempty (find (missing0, 1));
398
399   if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo))
400     if (dbug), fprintf ('\nTrying to add missing UNO java class libs to javaclasspath...\n'); end %if
401     if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if
402     % Add missing jars to javaclasspath. First combine all entries
403     targt = sum (missing0);
404     if (missing0(1))
405       % Add program dir (= where soffice or soffice.exe or ooffice resides)
406       programdir = [path_to_ooo filesep entries0{1}];
407       if (exist (programdir, 'dir'))
408         if (dbug > 2), fprintf ('  Found %s, adding it to javaclasspath ... ', programdir); end %if
409         try
410           javaaddpath (programdir);
411           targt = targt - 1;
412           if (dbug > 2), fprintf ('OK\n'); end %if
413         catch
414           if (dbug > 2), fprintf ('FAILED\n'); end %if
415         end %try_catch
416       else
417         if (dbug > 2), error ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); end %if
418       end %if
419     end %if
420     % Rest of missing entries. Find where URE is located. Watch out because case of ./ure is unknown
421     uredir = get_dir_ (path_to_ooo, 'ure');
422     if (isempty (uredir)), return; end %if
423     % Now search for UNO jars
424     for ii=2:length (entries0)
425       if (missing0(ii))
426         if (ii == 2)
427           % Special case as unoil.jar usually resides in ./Basis<something>/program/classes
428           % Find out the exact name of Basis.....
429           basisdirlst = dir ([path_to_ooo filesep '?asis' '*']);
430           jj = 1;
431           if (numel (basisdirlst) > 0) 
432             while (jj <= size (basisdirlst, 1) && jj > 0)
433               basisdir = basisdirlst(jj).name;
434               if (basisdirlst(jj).isdir)
435                 basisdir = basisdirlst(jj).name;
436                 jj = 0;
437               else
438                 jj = jj + 1;
439               end %if
440             end %while
441             basisdir = [path_to_ooo filesep basisdir ];
442           else
443             basisdir = path_to_ooo;
444           endif
445           basisdirentries = {'program', 'classes'};
446           tmp = basisdir; jj=1;
447           while (~isempty (tmp) && jj <= numel (basisdirentries))
448             tmp = get_dir_ (tmp, basisdirentries{jj});
449             jj = jj + 1;
450           end %if
451           unojarpath = tmp;
452           file = dir ([ unojarpath filesep entries0{2} '*' ]);
453         else
454           % Rest of jars in ./ure/share/java or ./ure/java
455           unojardir = get_dir_ (uredir, 'share');
456           if (isempty (unojardir))
457             tmp = uredir;
458           else
459             tmp = unojardir;
460           end %if
461           unojarpath = get_dir_ (tmp, 'java');
462           file = dir ([unojarpath filesep entries0{ii} '*']);
463         end %if
464         % Path found, now try to add jar
465         if (isempty (file))
466           if (dbug > 2), fprintf ('  ? %s<...>.jar ?\n', entries0{ii}); end %if
467         else
468           if (dbug > 2), fprintf ('  Found %s, adding it to javaclasspath ... ', file.name); end %if
469           try
470             javaaddpath ([unojarpath filesep file.name]);
471             targt = targt - 1;
472             if (dbug > 2), fprintf ('OK\n'); end %if
473           catch
474             if (dbug > 2), fprintf ('FAILED\n'); end %if
475                     end %try_catch
476         end %if
477       end %if
478     end %for
479     if (~targt); retval = retval + 128; end %if
480     if (dbug)
481       if (targt)
482         fprintf ('Some UNO class libs still lacking...\n\n'); 
483       else
484         fprintf ('UNO interface supported now.\n\n');
485       end %if
486     end %f
487   end %if
488
489 % ----------Rest of Java interfaces----------------------------------
490
491   missing = [missing1 missing2 missing3 missing4 missing5 missing6];
492   jars_complete = isempty (find (missing, 1));
493   if (dbug)
494     if (jars_complete)
495       fprintf ('All interfaces already fully supported.\n\n');
496     else
497       fprintf ('Some class libs lacking yet...\n\n'); 
498     end %if
499   end %if
500
501   if (~jars_complete && nargin > 0 && ~isempty (path_to_jars))
502     % Add missing jars to javaclasspath. Assume they're all in the same place
503     if (dbug), fprintf ('Trying to add missing java class libs to javaclasspath...\n'); end %if
504     if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if
505     % First combine all entries
506     targt = sum (missing);
507     % Search tru list of missing entries
508     for ii=1:6   % Adapt in case of future new interfaces
509       tmpe = eval ([ 'entries' char(ii + '0') ]);
510       tmpm = eval ([ 'missing' char(ii + '0') ]);
511       if (sum (tmpm))
512         for jj=1:numel (tmpe)
513           if (tmpm(jj))
514             file = dir ([path_to_jars filesep tmpe{jj} '*']);
515             if (isempty (file))
516               if (dbug > 2), fprintf ('  ? %s<...>.jar ?\n', tmpe{jj}); end %if
517             else
518               if (dbug > 2), fprintf ('  Found %s, adding it to javaclasspath ... ', file(1).name); end %if
519               try
520                 javaaddpath ([path_to_jars filesep file(1).name]);
521                 targt = targt - 1;
522                 tmpm(jj) = 0;
523                 if (dbug > 2), fprintf ('OK\n'); end %if
524               catch
525                 if (dbug > 2), fprintf ('FAILED\n'); end %if
526               end %try_catch
527             end %if
528           end %if
529         end %for
530         if (~sum (tmpm))
531           retval = retval + 2^ii;
532         end %if
533       end %if
534     end %for
535     if (dbug)
536       if (targt)
537         fprintf ('Some other class libs still lacking...\n\n');
538       else
539         fprintf ('All interfaces fully supported.now.\n\n');
540       end %if
541     end %f
542   end %if
543
544 end %function
545
546
547 function [ ret_dir ] = get_dir_ (base_dir, req_dir)
548
549 % Construct path to subdirectory req_dir in a subdir tree, aimed
550 % at taking care of proper case (esp. for *nix) of existing subdir
551 % in the result. Case of input var req_dir is ignored on purpose.
552
553   ret_dir = '';
554   % Get list of directory entries
555   ret_dir_list = dir (base_dir);
556   % Find matching entries
557   idx = find (strcmpi ({ret_dir_list.name}, req_dir));
558   % On *nix, several files and subdirs in one dir may have the same name as long as case differs
559   if (~isempty (idx))
560     ii = 1;
561     while (~ret_dir_list(idx(ii)).isdir)
562       ii = ii + 1;
563       if (ii > numel (idx)); return; end %if
564     end %while
565     % If we get here, a dir with proper name has been found. Construct path
566     ret_dir = [ base_dir filesep  ret_dir_list(idx(ii)).name ];
567   end %if
568
569 end %function