KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > lang > SystemUtils


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.lang;
17
18 import java.io.File JavaDoc;
19
20 /**
21  * <p>Helpers for <code>java.lang.System</code>.</p>
22  *
23  * <p>If a system property cannot be read due to security restrictions,
24  * the corresponding field in this class will be set to <code>null</code>
25  * and a message will be written to <code>System.err</code>.</p>
26  *
27  * @author Based on code from Avalon Excalibur
28  * @author Based on code from Lucene
29  * @author Stephen Colebourne
30  * @author <a HREF="mailto:sdowney@panix.com">Steve Downey</a>
31  * @author Gary Gregory
32  * @author Michael Becke
33  * @author Tetsuya Kaneuchi
34  * @author Rafal Krupinski
35  * @author Jason Gritman
36  * @since 1.0
37  * @version $Id: SystemUtils.java 165657 2005-05-02 18:31:49Z ggregory $
38  */

39 public class SystemUtils {
40
41     /**
42      * The prefix String for all Windows OS.
43      */

44     private static final String JavaDoc OS_NAME_WINDOWS_PREFIX = "Windows";
45     
46     // System property constants
47
//-----------------------------------------------------------------------
48
// These MUST be declared first. Other constants depend on this.
49

50     /**
51      * The System property key for the user home directory.
52      */

53     private static final String JavaDoc USER_HOME_KEY = "user.home";
54
55     /**
56      * The System property key for the user directory.
57      */

58     private static final String JavaDoc USER_DIR_KEY = "user.dir";
59     
60     /**
61      * The System property key for the Java IO temporary directory.
62      */

63     private static final String JavaDoc JAVA_IO_TMPDIR_KEY = "java.io.tmpdir";
64     
65     /**
66      * The System property key for the Java home directory.
67      */

68     private static final String JavaDoc JAVA_HOME_KEY = "java.home";
69     
70     /**
71      * <p>The <code>awt.toolkit</code> System Property.</p>
72      * <p>Holds a class name, on Windows XP this is <code>sun.awt.windows.WToolkit</code>.</p>
73      * <p><b>On platforms without a GUI, this value is <code>null</code>.</b></p>
74      *
75      * <p>Defaults to <code>null</code> if the runtime does not have
76      * security access to read this property or the property does not exist.</p>
77      *
78      * <p>
79      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
80      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
81      * will be out of sync with that System property.
82      * </p>
83      *
84      * @since 2.1
85      */

86     public static final String JavaDoc AWT_TOOLKIT = getSystemProperty("awt.toolkit");
87
88     /**
89      * <p>The <code>file.encoding</code> System Property.</p>
90      * <p>File encoding, such as <code>Cp1252</code>.</p>
91      *
92      * <p>Defaults to <code>null</code> if the runtime does not have
93      * security access to read this property or the property does not exist.</p>
94      *
95      * <p>
96      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
97      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
98      * will be out of sync with that System property.
99      * </p>
100      *
101      * @since 2.0
102      * @since Java 1.2
103      */

104     public static final String JavaDoc FILE_ENCODING = getSystemProperty("file.encoding");
105
106     /**
107      * <p>The <code>file.separator</code> System Property.
108      * File separator (<code>&quot;/&quot;</code> on UNIX).</p>
109      *
110      * <p>Defaults to <code>null</code> if the runtime does not have
111      * security access to read this property or the property does not exist.</p>
112      *
113      * <p>
114      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
115      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
116      * will be out of sync with that System property.
117      * </p>
118      *
119      * @since Java 1.1
120      */

121     public static final String JavaDoc FILE_SEPARATOR = getSystemProperty("file.separator");
122
123     /**
124      * <p>The <code>java.awt.fonts</code> System Property.</p>
125      *
126      * <p>Defaults to <code>null</code> if the runtime does not have
127      * security access to read this property or the property does not exist.</p>
128      *
129      * <p>
130      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
131      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
132      * will be out of sync with that System property.
133      * </p>
134      *
135      * @since 2.1
136      */

137     public static final String JavaDoc JAVA_AWT_FONTS = getSystemProperty("java.awt.fonts");
138
139     /**
140      * <p>The <code>java.awt.graphicsenv</code> System Property.</p>
141      *
142      * <p>Defaults to <code>null</code> if the runtime does not have
143      * security access to read this property or the property does not exist.</p>
144      *
145      * <p>
146      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
147      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
148      * will be out of sync with that System property.
149      * </p>
150      *
151      * @since 2.1
152      */

153     public static final String JavaDoc JAVA_AWT_GRAPHICSENV = getSystemProperty("java.awt.graphicsenv");
154
155     /**
156      * <p>
157      * The <code>java.awt.headless</code> System Property.
158      * The value of this property is the String <code>"true"</code> or <code>"false"</code>.
159      * </p>
160      *
161      * <p>Defaults to <code>null</code> if the runtime does not have
162      * security access to read this property or the property does not exist.</p>
163      *
164      * <p>
165      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
166      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
167      * will be out of sync with that System property.
168      * </p>
169      *
170      * @see #isJavaAwtHeadless()
171      * @since 2.1
172      * @since Java 1.4
173      */

174     public static final String JavaDoc JAVA_AWT_HEADLESS = getSystemProperty("java.awt.headless");
175
176     /**
177      * <p>The <code>java.awt.printerjob</code> System Property.</p>
178      *
179      * <p>Defaults to <code>null</code> if the runtime does not have
180      * security access to read this property or the property does not exist.</p>
181      *
182      * <p>
183      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
184      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
185      * will be out of sync with that System property.
186      * </p>
187      *
188      * @since 2.1
189      */

190     public static final String JavaDoc JAVA_AWT_PRINTERJOB = getSystemProperty("java.awt.printerjob");
191
192     /**
193      * <p>The <code>java.class.path</code> System Property. Java class path.</p>
194      *
195      * <p>Defaults to <code>null</code> if the runtime does not have
196      * security access to read this property or the property does not exist.</p>
197      *
198      * <p>
199      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
200      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
201      * will be out of sync with that System property.
202      * </p>
203      *
204      * @since Java 1.1
205      */

206     public static final String JavaDoc JAVA_CLASS_PATH = getSystemProperty("java.class.path");
207
208     /**
209      * <p>The <code>java.class.version</code> System Property.
210      * Java class format version number.</p>
211      *
212      * <p>Defaults to <code>null</code> if the runtime does not have
213      * security access to read this property or the property does not exist.</p>
214      *
215      * <p>
216      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
217      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
218      * will be out of sync with that System property.
219      * </p>
220      *
221      * @since Java 1.1
222      */

223     public static final String JavaDoc JAVA_CLASS_VERSION = getSystemProperty("java.class.version");
224
225     /**
226      * <p>The <code>java.compiler</code> System Property. Name of JIT compiler to use.
227      * First in JDK version 1.2. Not used in Sun JDKs after 1.2.</p>
228      *
229      * <p>Defaults to <code>null</code> if the runtime does not have
230      * security access to read this property or the property does not exist.</p>
231      *
232      * <p>
233      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
234      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
235      * will be out of sync with that System property.
236      * </p>
237      *
238      * @since Java 1.2. Not used in Sun versions after 1.2.
239      */

240     public static final String JavaDoc JAVA_COMPILER = getSystemProperty("java.compiler");
241
242     /**
243      * <p>The <code>java.endorsed.dirs</code> System Property. Path of endorsed directory
244      * or directories.</p>
245      *
246      * <p>Defaults to <code>null</code> if the runtime does not have
247      * security access to read this property or the property does not exist.</p>
248      *
249      * <p>
250      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
251      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
252      * will be out of sync with that System property.
253      * </p>
254      *
255      * @since Java 1.4
256      */

257     public static final String JavaDoc JAVA_ENDORSED_DIRS = getSystemProperty("java.endorsed.dirs");
258
259     /**
260      * <p>The <code>java.ext.dirs</code> System Property. Path of extension directory
261      * or directories.</p>
262      *
263      * <p>Defaults to <code>null</code> if the runtime does not have
264      * security access to read this property or the property does not exist.</p>
265      *
266      * <p>
267      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
268      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
269      * will be out of sync with that System property.
270      * </p>
271      *
272      * @since Java 1.3
273      */

274     public static final String JavaDoc JAVA_EXT_DIRS = getSystemProperty("java.ext.dirs");
275
276     /**
277      * <p>The <code>java.home</code> System Property. Java installation directory.</p>
278      *
279      * <p>Defaults to <code>null</code> if the runtime does not have
280      * security access to read this property or the property does not exist.</p>
281      *
282      * <p>
283      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
284      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
285      * will be out of sync with that System property.
286      * </p>
287      *
288      * @since Java 1.1
289      */

290     public static final String JavaDoc JAVA_HOME = getSystemProperty(JAVA_HOME_KEY);
291
292     /**
293      * <p>The <code>java.io.tmpdir</code> System Property. Default temp file path.</p>
294      *
295      * <p>Defaults to <code>null</code> if the runtime does not have
296      * security access to read this property or the property does not exist.</p>
297      *
298      * <p>
299      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
300      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
301      * will be out of sync with that System property.
302      * </p>
303      *
304      * @since Java 1.2
305      */

306     public static final String JavaDoc JAVA_IO_TMPDIR = getSystemProperty(JAVA_IO_TMPDIR_KEY);
307
308     /**
309      * <p>The <code>java.library.path</code> System Property. List of paths to search
310      * when loading libraries.</p>
311      *
312      * <p>Defaults to <code>null</code> if the runtime does not have
313      * security access to read this property or the property does not exist.</p>
314      *
315      * <p>
316      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
317      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
318      * will be out of sync with that System property.
319      * </p>
320      *
321      * @since Java 1.2
322      */

323     public static final String JavaDoc JAVA_LIBRARY_PATH = getSystemProperty("java.library.path");
324
325     /**
326      * <p>The <code>java.runtime.name</code> System Property. Java Runtime Environment
327      * name.</p>
328      *
329      * <p>Defaults to <code>null</code> if the runtime does not have
330      * security access to read this property or the property does not exist.</p>
331      *
332      * <p>
333      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
334      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
335      * will be out of sync with that System property.
336      * </p>
337      *
338      * @since 2.0
339      * @since Java 1.3
340      */

341     public static final String JavaDoc JAVA_RUNTIME_NAME = getSystemProperty("java.runtime.name");
342
343     /**
344      * <p>The <code>java.runtime.version</code> System Property. Java Runtime Environment
345      * version.</p>
346      *
347      * <p>Defaults to <code>null</code> if the runtime does not have
348      * security access to read this property or the property does not exist.</p>
349      *
350      * <p>
351      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
352      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
353      * will be out of sync with that System property.
354      * </p>
355      *
356      * @since 2.0
357      * @since Java 1.3
358      */

359     public static final String JavaDoc JAVA_RUNTIME_VERSION = getSystemProperty("java.runtime.version");
360
361     /**
362      * <p>The <code>java.specification.name</code> System Property. Java Runtime Environment
363      * specification name.</p>
364      *
365      * <p>Defaults to <code>null</code> if the runtime does not have
366      * security access to read this property or the property does not exist.</p>
367      *
368      * <p>
369      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
370      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
371      * will be out of sync with that System property.
372      * </p>
373      *
374      * @since Java 1.2
375      */

376     public static final String JavaDoc JAVA_SPECIFICATION_NAME = getSystemProperty("java.specification.name");
377
378     /**
379      * <p>The <code>java.specification.vendor</code> System Property. Java Runtime Environment
380      * specification vendor.</p>
381      *
382      * <p>Defaults to <code>null</code> if the runtime does not have
383      * security access to read this property or the property does not exist.</p>
384      *
385      * <p>
386      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
387      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
388      * will be out of sync with that System property.
389      * </p>
390      *
391      * @since Java 1.2
392      */

393     public static final String JavaDoc JAVA_SPECIFICATION_VENDOR = getSystemProperty("java.specification.vendor");
394
395     /**
396      * <p>The <code>java.specification.version</code> System Property. Java Runtime Environment
397      * specification version.</p>
398      *
399      * <p>Defaults to <code>null</code> if the runtime does not have
400      * security access to read this property or the property does not exist.</p>
401      *
402      * <p>
403      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
404      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
405      * will be out of sync with that System property.
406      * </p>
407      *
408      * @since Java 1.3
409      */

410     public static final String JavaDoc JAVA_SPECIFICATION_VERSION = getSystemProperty("java.specification.version");
411
412     /**
413      * <p>The <code>java.util.prefs.PreferencesFactory</code> System Property. A class name.</p>
414      *
415      * <p>Defaults to <code>null</code> if the runtime does not have
416      * security access to read this property or the property does not exist.</p>
417      *
418      * <p>
419      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
420      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
421      * will be out of sync with that System property.
422      * </p>
423      *
424      * @since 2.1
425      * @since Java 1.4
426      */

427     public static final String JavaDoc JAVA_UTIL_PREFS_PREFERENCES_FACTORY =
428         getSystemProperty("java.util.prefs.PreferencesFactory");
429
430     /**
431      * <p>The <code>java.vendor</code> System Property. Java vendor-specific string.</p>
432      *
433      * <p>Defaults to <code>null</code> if the runtime does not have
434      * security access to read this property or the property does not exist.</p>
435      *
436      * <p>
437      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
438      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
439      * will be out of sync with that System property.
440      * </p>
441      *
442      * @since Java 1.1
443      */

444     public static final String JavaDoc JAVA_VENDOR = getSystemProperty("java.vendor");
445
446     /**
447      * <p>The <code>java.vendor.url</code> System Property. Java vendor URL.</p>
448      *
449      * <p>Defaults to <code>null</code> if the runtime does not have
450      * security access to read this property or the property does not exist.</p>
451      *
452      * <p>
453      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
454      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
455      * will be out of sync with that System property.
456      * </p>
457      *
458      * @since Java 1.1
459     */

460     public static final String JavaDoc JAVA_VENDOR_URL = getSystemProperty("java.vendor.url");
461
462     /**
463      * <p>The <code>java.version</code> System Property. Java version number.</p>
464      *
465      * <p>Defaults to <code>null</code> if the runtime does not have
466      * security access to read this property or the property does not exist.</p>
467      *
468      * <p>
469      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
470      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
471      * will be out of sync with that System property.
472      * </p>
473      *
474      * @since Java 1.1
475      */

476     public static final String JavaDoc JAVA_VERSION = getSystemProperty("java.version");
477
478     /**
479      * <p>The <code>java.vm.info</code> System Property. Java Virtual Machine implementation
480      * info.</p>
481      *
482      * <p>Defaults to <code>null</code> if the runtime does not have
483      * security access to read this property or the property does not exist.</p>
484      *
485      * <p>
486      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
487      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
488      * will be out of sync with that System property.
489      * </p>
490      *
491      * @since 2.0
492      * @since Java 1.2
493      */

494     public static final String JavaDoc JAVA_VM_INFO = getSystemProperty("java.vm.info");
495
496     /**
497      * <p>The <code>java.vm.name</code> System Property. Java Virtual Machine implementation
498      * name.</p>
499      *
500      * <p>Defaults to <code>null</code> if the runtime does not have
501      * security access to read this property or the property does not exist.</p>
502      *
503      * <p>
504      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
505      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
506      * will be out of sync with that System property.
507      * </p>
508      *
509      * @since Java 1.2
510      */

511     public static final String JavaDoc JAVA_VM_NAME = getSystemProperty("java.vm.name");
512
513     /**
514      * <p>The <code>java.vm.specification.name</code> System Property. Java Virtual Machine
515      * specification name.</p>
516      *
517      * <p>Defaults to <code>null</code> if the runtime does not have
518      * security access to read this property or the property does not exist.</p>
519      *
520      * <p>
521      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
522      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
523      * will be out of sync with that System property.
524      * </p>
525      *
526      * @since Java 1.2
527      */

528     public static final String JavaDoc JAVA_VM_SPECIFICATION_NAME = getSystemProperty("java.vm.specification.name");
529
530     /**
531      * <p>The <code>java.vm.specification.vendor</code> System Property. Java Virtual
532      * Machine specification vendor.</p>
533      *
534      * <p>Defaults to <code>null</code> if the runtime does not have
535      * security access to read this property or the property does not exist.</p>
536      *
537      * <p>
538      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
539      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
540      * will be out of sync with that System property.
541      * </p>
542      *
543      * @since Java 1.2
544      */

545     public static final String JavaDoc JAVA_VM_SPECIFICATION_VENDOR = getSystemProperty("java.vm.specification.vendor");
546
547     /**
548      * <p>The <code>java.vm.specification.version</code> System Property. Java Virtual Machine
549      * specification version.</p>
550      *
551      * <p>Defaults to <code>null</code> if the runtime does not have
552      * security access to read this property or the property does not exist.</p>
553      *
554      * <p>
555      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
556      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
557      * will be out of sync with that System property.
558      * </p>
559      *
560      * @since Java 1.2
561      */

562     public static final String JavaDoc JAVA_VM_SPECIFICATION_VERSION = getSystemProperty("java.vm.specification.version");
563
564     /**
565      * <p>The <code>java.vm.vendor</code> System Property. Java Virtual Machine implementation
566      * vendor.</p>
567      *
568      * <p>Defaults to <code>null</code> if the runtime does not have
569      * security access to read this property or the property does not exist.</p>
570      *
571      * <p>
572      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
573      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
574      * will be out of sync with that System property.
575      * </p>
576      *
577      * @since Java 1.2
578      */

579     public static final String JavaDoc JAVA_VM_VENDOR = getSystemProperty("java.vm.vendor");
580
581     /**
582      * <p>The <code>java.vm.version</code> System Property. Java Virtual Machine
583      * implementation version.</p>
584      *
585      * <p>Defaults to <code>null</code> if the runtime does not have
586      * security access to read this property or the property does not exist.</p>
587      *
588      * <p>
589      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
590      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
591      * will be out of sync with that System property.
592      * </p>
593      *
594      * @since Java 1.2
595      */

596     public static final String JavaDoc JAVA_VM_VERSION = getSystemProperty("java.vm.version");
597
598     /**
599      * <p>The <code>line.separator</code> System Property. Line separator
600      * (<code>&quot;\n&quot;</code> on UNIX).</p>
601      *
602      * <p>Defaults to <code>null</code> if the runtime does not have
603      * security access to read this property or the property does not exist.</p>
604      *
605      * <p>
606      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
607      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
608      * will be out of sync with that System property.
609      * </p>
610      *
611      * @since Java 1.1
612      */

613     public static final String JavaDoc LINE_SEPARATOR = getSystemProperty("line.separator");
614
615     /**
616      * <p>The <code>os.arch</code> System Property. Operating system architecture.</p>
617      *
618      * <p>Defaults to <code>null</code> if the runtime does not have
619      * security access to read this property or the property does not exist.</p>
620      *
621      * <p>
622      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
623      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
624      * will be out of sync with that System property.
625      * </p>
626      *
627      * @since Java 1.1
628      */

629     public static final String JavaDoc OS_ARCH = getSystemProperty("os.arch");
630
631     /**
632      * <p>The <code>os.name</code> System Property. Operating system name.</p>
633      *
634      * <p>Defaults to <code>null</code> if the runtime does not have
635      * security access to read this property or the property does not exist.</p>
636      *
637      * <p>
638      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
639      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
640      * will be out of sync with that System property.
641      * </p>
642      *
643      * @since Java 1.1
644      */

645     public static final String JavaDoc OS_NAME = getSystemProperty("os.name");
646
647     /**
648      * <p>The <code>os.version</code> System Property. Operating system version.</p>
649      *
650      * <p>Defaults to <code>null</code> if the runtime does not have
651      * security access to read this property or the property does not exist.</p>
652      *
653      * <p>
654      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
655      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
656      * will be out of sync with that System property.
657      * </p>
658      *
659      * @since Java 1.1
660      */

661     public static final String JavaDoc OS_VERSION = getSystemProperty("os.version");
662
663     /**
664      * <p>The <code>path.separator</code> System Property. Path separator
665      * (<code>&quot;:&quot;</code> on UNIX).</p>
666      *
667      * <p>Defaults to <code>null</code> if the runtime does not have
668      * security access to read this property or the property does not exist.</p>
669      *
670      * <p>
671      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
672      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
673      * will be out of sync with that System property.
674      * </p>
675      *
676      * @since Java 1.1
677      */

678     public static final String JavaDoc PATH_SEPARATOR = getSystemProperty("path.separator");
679
680     /**
681      * <p>The <code>user.country</code> or <code>user.region</code> System Property.
682      * User's country code, such as <code>GB</code>. First in JDK version 1.2 as
683      * <code>user.region</code>. Renamed to <code>user.country</code> in 1.4</p>
684      *
685      * <p>Defaults to <code>null</code> if the runtime does not have
686      * security access to read this property or the property does not exist.</p>
687      *
688      * <p>
689      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
690      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
691      * will be out of sync with that System property.
692      * </p>
693      *
694      * @since 2.0
695      * @since Java 1.2
696      */

697     public static final String JavaDoc USER_COUNTRY =
698         (getSystemProperty("user.country") == null ?
699             getSystemProperty("user.region") : getSystemProperty("user.country"));
700
701     /**
702      * <p>The <code>user.dir</code> System Property. User's current working
703      * directory.</p>
704      *
705      * <p>Defaults to <code>null</code> if the runtime does not have
706      * security access to read this property or the property does not exist.</p>
707      *
708      * <p>
709      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
710      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
711      * will be out of sync with that System property.
712      * </p>
713      *
714      * @since Java 1.1
715      */

716     public static final String JavaDoc USER_DIR = getSystemProperty(USER_DIR_KEY);
717
718     /**
719      * <p>The <code>user.home</code> System Property. User's home directory.</p>
720      *
721      * <p>Defaults to <code>null</code> if the runtime does not have
722      * security access to read this property or the property does not exist.</p>
723      *
724      * <p>
725      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
726      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
727      * will be out of sync with that System property.
728      * </p>
729      *
730      * @since Java 1.1
731      */

732     public static final String JavaDoc USER_HOME = getSystemProperty(USER_HOME_KEY);
733
734     /**
735      * <p>The <code>user.language</code> System Property. User's language code,
736      * such as <code>"en"</code>.</p>
737      *
738      * <p>Defaults to <code>null</code> if the runtime does not have
739      * security access to read this property or the property does not exist.</p>
740      *
741      * <p>
742      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
743      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
744      * will be out of sync with that System property.
745      * </p>
746      *
747      * @since 2.0
748      * @since Java 1.2
749      */

750     public static final String JavaDoc USER_LANGUAGE = getSystemProperty("user.language");
751
752     /**
753      * <p>The <code>user.name</code> System Property. User's account name.</p>
754      *
755      * <p>Defaults to <code>null</code> if the runtime does not have
756      * security access to read this property or the property does not exist.</p>
757      *
758      * <p>
759      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
760      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
761      * will be out of sync with that System property.
762      * </p>
763      *
764      * @since Java 1.1
765      */

766     public static final String JavaDoc USER_NAME = getSystemProperty("user.name");
767
768     /**
769      * <p>The <code>user.timezone</code> System Property.
770      * For example: <code>"America/Los_Angeles"</code>.</p>
771      *
772      * <p>Defaults to <code>null</code> if the runtime does not have
773      * security access to read this property or the property does not exist.</p>
774      *
775      * <p>
776      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
777      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
778      * will be out of sync with that System property.
779      * </p>
780      *
781      * @since 2.1
782      */

783     public static final String JavaDoc USER_TIMEZONE = getSystemProperty("user.timezone");
784
785     // Java version
786
//-----------------------------------------------------------------------
787
// This MUST be declared after those above as it depends on the
788
// values being set up
789

790     /**
791      * <p>Gets the Java version as a <code>String</code> trimming leading letters.</p>
792      *
793      * <p>The field will return <code>null</code> if {@link #JAVA_VERSION} is <code>null</code>.</p>
794      *
795      * @since 2.1
796      */

797     public static final String JavaDoc JAVA_VERSION_TRIMMED = getJavaVersionTrimmed();
798
799     // Java version values
800
//-----------------------------------------------------------------------
801
// These MUST be declared after the trim above as they depend on the
802
// value being set up
803

804     /**
805      * <p>Gets the Java version as a <code>float</code>.</p>
806      *
807      * <p>Example return values:</p>
808      * <ul>
809      * <li><code>1.2f</code> for JDK 1.2
810      * <li><code>1.31f</code> for JDK 1.3.1
811      * </ul>
812      *
813      * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
814      *
815      * @since 2.0
816      */

817     public static final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat();
818
819     /**
820      * <p>Gets the Java version as an <code>int</code>.</p>
821      *
822      * <p>Example return values:</p>
823      * <ul>
824      * <li><code>120</code> for JDK 1.2
825      * <li><code>131</code> for JDK 1.3.1
826      * </ul>
827      *
828      * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
829      *
830      * @since 2.0
831      */

832     public static final int JAVA_VERSION_INT = getJavaVersionAsInt();
833
834     // Java version checks
835
//-----------------------------------------------------------------------
836
// These MUST be declared after those above as they depend on the
837
// values being set up
838

839     /**
840      * <p>Is <code>true</code> if this is Java version 1.1 (also 1.1.x versions).</p>
841      *
842      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
843      * <code>null</code>.</p>
844      */

845     public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");
846
847     /**
848      * <p>Is <code>true</code> if this is Java version 1.2 (also 1.2.x versions).</p>
849      *
850      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
851      * <code>null</code>.</p>
852      */

853     public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2");
854
855     /**
856      * <p>Is <code>true</code> if this is Java version 1.3 (also 1.3.x versions).</p>
857      *
858      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
859      * <code>null</code>.</p>
860      */

861     public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3");
862
863     /**
864      * <p>Is <code>true</code> if this is Java version 1.4 (also 1.4.x versions).</p>
865      *
866      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
867      * <code>null</code>.</p>
868      */

869     public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4");
870
871     /**
872      * <p>Is <code>true</code> if this is Java version 1.5 (also 1.5.x versions).</p>
873      *
874      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
875      * <code>null</code>.</p>
876      */

877     public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5");
878
879     // Operating system checks
880
//-----------------------------------------------------------------------
881
// These MUST be declared after those above as they depend on the
882
// values being set up
883
// OS names from http://www.vamphq.com/os.html
884
// Selected ones included - please advise commons-dev@jakarta.apache.org
885
// if you want another added or a mistake corrected
886

887     /**
888      * <p>Is <code>true</code> if this is AIX.</p>
889      *
890      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
891      * <code>null</code>.</p>
892      *
893      * @since 2.0
894      */

895     public static final boolean IS_OS_AIX = getOSMatches("AIX");
896
897     /**
898      * <p>Is <code>true</code> if this is HP-UX.</p>
899      *
900      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
901      * <code>null</code>.</p>
902      *
903      * @since 2.0
904      */

905     public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX");
906
907     /**
908      * <p>Is <code>true</code> if this is Irix.</p>
909      *
910      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
911      * <code>null</code>.</p>
912      *
913      * @since 2.0
914      */

915     public static final boolean IS_OS_IRIX = getOSMatches("Irix");
916
917     /**
918      * <p>Is <code>true</code> if this is Linux.</p>
919      *
920      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
921      * <code>null</code>.</p>
922      *
923      * @since 2.0
924      */

925     public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX");
926
927     /**
928      * <p>Is <code>true</code> if this is Mac.</p>
929      *
930      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
931      * <code>null</code>.</p>
932      *
933      * @since 2.0
934      */

935     public static final boolean IS_OS_MAC = getOSMatches("Mac");
936
937     /**
938      * <p>Is <code>true</code> if this is Mac.</p>
939      *
940      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
941      * <code>null</code>.</p>
942      *
943      * @since 2.0
944      */

945     public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X");
946
947     /**
948      * <p>Is <code>true</code> if this is OS/2.</p>
949      *
950      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
951      * <code>null</code>.</p>
952      *
953      * @since 2.0
954      */

955     public static final boolean IS_OS_OS2 = getOSMatches("OS/2");
956
957     /**
958      * <p>Is <code>true</code> if this is Solaris.</p>
959      *
960      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
961      * <code>null</code>.</p>
962      *
963      * @since 2.0
964      */

965     public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris");
966
967     /**
968      * <p>Is <code>true</code> if this is SunOS.</p>
969      *
970      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
971      * <code>null</code>.</p>
972      *
973      * @since 2.0
974      */

975     public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS");
976
977     /**
978      * <p>Is <code>true</code> if this is a POSIX compilant system,
979      * as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.</p>
980      *
981      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
982      * <code>null</code>.</p>
983      *
984      * @since 2.1
985      */

986