001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      https://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.lang3;
018
019import java.io.File;
020import java.nio.file.Path;
021import java.nio.file.Paths;
022
023/**
024 * Helpers for {@link System}.
025 *
026 * <p>
027 * If a system property cannot be read due to security restrictions, the corresponding field in this class will be set to {@code null} and a message will be
028 * written to {@code System.err}.
029 * </p>
030 * <p>
031 * #ThreadSafe#
032 * </p>
033 *
034 * @since 1.0
035 * @see SystemProperties
036 */
037public class SystemUtils {
038
039    /**
040     * The prefix String for all Windows OS.
041     */
042    private static final String OS_NAME_WINDOWS_PREFIX = "Windows";
043
044    // System property constants
045    // -----------------------------------------------------------------------
046    // These MUST be declared first. Other constants depend on this.
047
048    /**
049     * A constant for the System Property {@code file.encoding}.
050     *
051     * <p>
052     * File encoding, such as {@code Cp1252}.
053     * </p>
054     * <p>
055     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
056     * </p>
057     * <p>
058     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
059     * called after this class is loaded, the value will be out of sync with that System property.
060     * </p>
061     *
062     * @see SystemProperties#getFileEncoding()
063     * @since 2.0
064     * @since Java 1.2
065     */
066    public static final String FILE_ENCODING = SystemProperties.getFileEncoding();
067
068    /**
069     * A constant for the System Property {@code file.separator}.
070     * <p>
071     * The file separator is:
072     * </p>
073     * <ul>
074     * <li>{@code "/"} on Unix</li>
075     * <li>{@code "\"} on Windows.</li>
076     * </ul>
077     *
078     * <p>
079     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
080     * </p>
081     * <p>
082     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
083     * called after this class is loaded, the value will be out of sync with that System property.
084     * </p>
085     *
086     * @see SystemProperties#getFileSeparator()
087     * @deprecated Use {@link File#separator}, since it is guaranteed to be a string containing a single character and it does not require a privilege check.
088     * @since Java 1.1
089     */
090    @Deprecated
091    public static final String FILE_SEPARATOR = SystemProperties.getFileSeparator();
092
093    /**
094     * A constant for the System Property {@code java.awt.fonts}.
095     *
096     * <p>
097     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
098     * </p>
099     * <p>
100     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
101     * called after this class is loaded, the value will be out of sync with that System property.
102     * </p>
103     *
104     * @see SystemProperties#getJavaAwtFonts()
105     * @since 2.1
106     */
107    public static final String JAVA_AWT_FONTS = SystemProperties.getJavaAwtFonts();
108
109    /**
110     * A constant for the System Property {@code java.awt.graphicsenv}.
111     *
112     * <p>
113     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
114     * </p>
115     * <p>
116     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
117     * called after this class is loaded, the value will be out of sync with that System property.
118     * </p>
119     *
120     * @see SystemProperties#getJavaAwtGraphicsenv()
121     * @since 2.1
122     */
123    public static final String JAVA_AWT_GRAPHICSENV = SystemProperties.getJavaAwtGraphicsenv();
124
125    /**
126     * A constant for the System Property {@code java.awt.headless}. The value of this property is the String {@code "true"} or {@code "false"}.
127     *
128     * <p>
129     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
130     * </p>
131     * <p>
132     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
133     * called after this class is loaded, the value will be out of sync with that System property.
134     * </p>
135     *
136     * @see #isJavaAwtHeadless()
137     * @see SystemProperties#getJavaAwtHeadless()
138     * @since 2.1
139     * @since Java 1.4
140     */
141    public static final String JAVA_AWT_HEADLESS = SystemProperties.getJavaAwtHeadless();
142
143    /**
144     * A constant for the System Property {@code java.awt.printerjob}.
145     *
146     * <p>
147     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
148     * </p>
149     * <p>
150     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
151     * called after this class is loaded, the value will be out of sync with that System property.
152     * </p>
153     *
154     * @see SystemProperties#getJavaAwtPrinterjob()
155     * @since 2.1
156     */
157    public static final String JAVA_AWT_PRINTERJOB = SystemProperties.getJavaAwtPrinterjob();
158
159    /**
160     * A constant for the System Property {@code java.class.path}. Java class path.
161     *
162     * <p>
163     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
164     * </p>
165     * <p>
166     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
167     * called after this class is loaded, the value will be out of sync with that System property.
168     * </p>
169     *
170     * @see SystemProperties#getJavaClassPath()
171     * @since Java 1.1
172     */
173    public static final String JAVA_CLASS_PATH = SystemProperties.getJavaClassPath();
174
175    /**
176     * A constant for the System Property {@code java.class.version}. Java class format version number.
177     *
178     * <p>
179     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
180     * </p>
181     * <p>
182     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
183     * called after this class is loaded, the value will be out of sync with that System property.
184     * </p>
185     *
186     * @see SystemProperties#getJavaClassVersion()
187     * @since Java 1.1
188     */
189    public static final String JAVA_CLASS_VERSION = SystemProperties.getJavaClassVersion();
190
191    /**
192     * A constant for the System Property {@code java.compiler}. Name of JIT compiler to use. First in JDK version 1.2. Not used in Sun JDKs after 1.2.
193     *
194     * <p>
195     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
196     * </p>
197     * <p>
198     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
199     * called after this class is loaded, the value will be out of sync with that System property.
200     * </p>
201     *
202     * @see SystemProperties#getJavaCompiler()
203     * @since Java 1.2. Not used in Sun versions after 1.2.
204     */
205    public static final String JAVA_COMPILER = SystemProperties.getJavaCompiler();
206
207    /**
208     * A constant for the System Property {@code java.endorsed.dirs}. Path of endorsed directory or directories.
209     *
210     * <p>
211     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
212     * </p>
213     * <p>
214     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
215     * called after this class is loaded, the value will be out of sync with that System property.
216     * </p>
217     *
218     * @see SystemProperties#getJavaEndorsedDirs()
219     * @since Java 1.4
220     */
221    public static final String JAVA_ENDORSED_DIRS = SystemProperties.getJavaEndorsedDirs();
222
223    /**
224     * A constant for the System Property {@code java.ext.dirs}. Path of extension directory or directories.
225     *
226     * <p>
227     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
228     * </p>
229     * <p>
230     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
231     * called after this class is loaded, the value will be out of sync with that System property.
232     * </p>
233     *
234     * @see SystemProperties#getJavaExtDirs()
235     * @since Java 1.3
236     */
237    public static final String JAVA_EXT_DIRS = SystemProperties.getJavaExtDirs();
238
239    /**
240     * A constant for the System Property {@code java.home}. Java installation directory.
241     *
242     * <p>
243     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
244     * </p>
245     * <p>
246     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
247     * called after this class is loaded, the value will be out of sync with that System property.
248     * </p>
249     *
250     * @see SystemProperties#getJavaHome()
251     * @since Java 1.1
252     */
253    public static final String JAVA_HOME = SystemProperties.getJavaHome();
254
255    /**
256     * A constant for the System Property {@code java.io.tmpdir}. Default temp file path.
257     *
258     * <p>
259     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
260     * </p>
261     * <p>
262     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
263     * called after this class is loaded, the value will be out of sync with that System property.
264     * </p>
265     *
266     * @see SystemProperties#getJavaIoTmpdir()
267     * @since Java 1.2
268     */
269    public static final String JAVA_IO_TMPDIR = SystemProperties.getJavaIoTmpdir();
270
271    /**
272     * A constant for the System Property {@code java.library.path}. List of paths to search when loading libraries.
273     *
274     * <p>
275     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
276     * </p>
277     * <p>
278     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
279     * called after this class is loaded, the value will be out of sync with that System property.
280     * </p>
281     *
282     * @see SystemProperties#getJavaLibraryPath()
283     * @since Java 1.2
284     */
285    public static final String JAVA_LIBRARY_PATH = SystemProperties.getJavaLibraryPath();
286
287    /**
288     * A constant for the System Property {@code java.runtime.name}. Java Runtime Environment name.
289     *
290     * <p>
291     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
292     * </p>
293     * <p>
294     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
295     * called after this class is loaded, the value will be out of sync with that System property.
296     * </p>
297     *
298     * @see SystemProperties#getJavaRuntimeName()
299     * @since 2.0
300     * @since Java 1.3
301     */
302    public static final String JAVA_RUNTIME_NAME = SystemProperties.getJavaRuntimeName();
303
304    /**
305     * A constant for the System Property {@code java.runtime.version}. Java Runtime Environment version.
306     *
307     * <p>
308     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
309     * </p>
310     * <p>
311     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
312     * called after this class is loaded, the value will be out of sync with that System property.
313     * </p>
314     *
315     * @see SystemProperties#getJavaRuntimeVersion()
316     * @since 2.0
317     * @since Java 1.3
318     */
319    public static final String JAVA_RUNTIME_VERSION = SystemProperties.getJavaRuntimeVersion();
320
321    /**
322     * A constant for the System Property {@code java.specification.name}. Java Runtime Environment specification name.
323     *
324     * <p>
325     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
326     * </p>
327     * <p>
328     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
329     * called after this class is loaded, the value will be out of sync with that System property.
330     * </p>
331     *
332     * @see SystemProperties#getJavaSpecificationName()
333     * @since Java 1.2
334     */
335    public static final String JAVA_SPECIFICATION_NAME = SystemProperties.getJavaSpecificationName();
336
337    /**
338     * A constant for the System Property {@code java.specification.vendor}. Java Runtime Environment specification vendor.
339     *
340     * <p>
341     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
342     * </p>
343     * <p>
344     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
345     * called after this class is loaded, the value will be out of sync with that System property.
346     * </p>
347     *
348     * @see SystemProperties#getJavaSpecificationVendor()
349     * @since Java 1.2
350     */
351    public static final String JAVA_SPECIFICATION_VENDOR = SystemProperties.getJavaSpecificationVendor();
352
353    /**
354     * A constant for the System Property {@code java.specification.version}. Java Runtime Environment specification version.
355     *
356     * <p>
357     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
358     * </p>
359     * <p>
360     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
361     * called after this class is loaded, the value will be out of sync with that System property.
362     * </p>
363     *
364     * @see SystemProperties#getJavaSpecificationVersion()
365     * @since Java 1.3
366     */
367    public static final String JAVA_SPECIFICATION_VERSION = SystemProperties.getJavaSpecificationVersion();
368
369    private static final JavaVersion JAVA_SPECIFICATION_VERSION_AS_ENUM = JavaVersion.get(JAVA_SPECIFICATION_VERSION);
370
371    /**
372     * A constant for the System Property {@code java.util.prefs.PreferencesFactory}. A class name.
373     *
374     * <p>
375     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
376     * </p>
377     * <p>
378     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
379     * called after this class is loaded, the value will be out of sync with that System property.
380     * </p>
381     *
382     * @see SystemProperties#getJavaUtilPrefsPreferencesFactory()
383     * @since 2.1
384     * @since Java 1.4
385     */
386    public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = SystemProperties.getJavaUtilPrefsPreferencesFactory();
387
388    /**
389     * A constant for the System Property {@code java.vendor}. Java vendor-specific string.
390     *
391     * <p>
392     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
393     * </p>
394     * <p>
395     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
396     * called after this class is loaded, the value will be out of sync with that System property.
397     * </p>
398     *
399     * @see SystemProperties#getJavaVendor()
400     * @since Java 1.1
401     */
402    public static final String JAVA_VENDOR = SystemProperties.getJavaVendor();
403
404    /**
405     * A constant for the System Property {@code java.vendor.url}. Java vendor URL.
406     *
407     * <p>
408     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
409     * </p>
410     * <p>
411     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
412     * called after this class is loaded, the value will be out of sync with that System property.
413     * </p>
414     *
415     * @see SystemProperties#getJavaVendorUrl()
416     * @since Java 1.1
417     */
418    public static final String JAVA_VENDOR_URL = SystemProperties.getJavaVendorUrl();
419
420    /**
421     * A constant for the System Property {@code java.version}. Java version number.
422     *
423     * <p>
424     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
425     * </p>
426     * <p>
427     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
428     * called after this class is loaded, the value will be out of sync with that System property.
429     * </p>
430     *
431     * @see SystemProperties#getJavaVersion()
432     * @since Java 1.1
433     */
434    public static final String JAVA_VERSION = SystemProperties.getJavaVersion();
435
436    /**
437     * A constant for the System Property {@code java.vm.info}. Java Virtual Machine implementation info.
438     *
439     * <p>
440     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
441     * </p>
442     * <p>
443     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
444     * called after this class is loaded, the value will be out of sync with that System property.
445     * </p>
446     *
447     * @see SystemProperties#getJavaVmInfo()
448     * @since 2.0
449     * @since Java 1.2
450     */
451    public static final String JAVA_VM_INFO = SystemProperties.getJavaVmInfo();
452
453    /**
454     * A constant for the System Property {@code java.vm.name}. Java Virtual Machine implementation name.
455     *
456     * <p>
457     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
458     * </p>
459     * <p>
460     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
461     * called after this class is loaded, the value will be out of sync with that System property.
462     * </p>
463     *
464     * @see SystemProperties#getJavaVmName()
465     * @since Java 1.2
466     */
467    public static final String JAVA_VM_NAME = SystemProperties.getJavaVmName();
468
469    /**
470     * A constant for the System Property {@code java.vm.specification.name}. Java Virtual Machine specification name.
471     *
472     * <p>
473     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
474     * </p>
475     * <p>
476     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
477     * called after this class is loaded, the value will be out of sync with that System property.
478     * </p>
479     *
480     * @see SystemProperties#getJavaVmSpecificationName()
481     * @since Java 1.2
482     */
483    public static final String JAVA_VM_SPECIFICATION_NAME = SystemProperties.getJavaVmSpecificationName();
484
485    /**
486     * A constant for the System Property {@code java.vm.specification.vendor}. Java Virtual Machine specification vendor.
487     *
488     * <p>
489     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
490     * </p>
491     * <p>
492     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
493     * called after this class is loaded, the value will be out of sync with that System property.
494     * </p>
495     *
496     * @see SystemProperties#getJavaVmSpecificationVendor()
497     * @since Java 1.2
498     */
499    public static final String JAVA_VM_SPECIFICATION_VENDOR = SystemProperties.getJavaVmSpecificationVendor();
500
501    /**
502     * A constant for the System Property {@code java.vm.specification.version}. Java Virtual Machine specification version.
503     *
504     * <p>
505     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
506     * </p>
507     * <p>
508     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
509     * called after this class is loaded, the value will be out of sync with that System property.
510     * </p>
511     *
512     * @see SystemProperties#getJavaVmSpecificationVersion()
513     * @since Java 1.2
514     */
515    public static final String JAVA_VM_SPECIFICATION_VERSION = SystemProperties.getJavaVmSpecificationVersion();
516
517    /**
518     * A constant for the System Property {@code java.vm.vendor}. Java Virtual Machine implementation vendor.
519     *
520     * <p>
521     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
522     * </p>
523     * <p>
524     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
525     * called after this class is loaded, the value will be out of sync with that System property.
526     * </p>
527     *
528     * @see SystemProperties#getJavaVmVendor()
529     * @since Java 1.2
530     */
531    public static final String JAVA_VM_VENDOR = SystemProperties.getJavaVmVendor();
532
533    /**
534     * A constant for the System Property {@code java.vm.version}. Java Virtual Machine implementation version.
535     *
536     * <p>
537     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
538     * </p>
539     * <p>
540     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
541     * called after this class is loaded, the value will be out of sync with that System property.
542     * </p>
543     *
544     * @see SystemProperties#getJavaVmVersion()
545     * @since Java 1.2
546     */
547    public static final String JAVA_VM_VERSION = SystemProperties.getJavaVmVersion();
548
549    /**
550     * A constant for the System Property {@code line.separator}. Line separator ({@code &quot;\n&quot;} on Unix).
551     *
552     * <p>
553     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
554     * </p>
555     * <p>
556     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
557     * called after this class is loaded, the value will be out of sync with that System property.
558     * </p>
559     *
560     * @see SystemProperties#getLineSeparator()
561     * @deprecated Use {@link System#lineSeparator()} instead, since it does not require a privilege check.
562     * @since Java 1.1
563     */
564    @Deprecated
565    public static final String LINE_SEPARATOR = SystemProperties.getLineSeparator();
566
567    /**
568     * A constant for the System Property {@code os.arch}. Operating system architecture.
569     *
570     * <p>
571     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
572     * </p>
573     * <p>
574     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
575     * called after this class is loaded, the value will be out of sync with that System property.
576     * </p>
577     *
578     * @see SystemProperties#getOsArch()
579     * @since Java 1.1
580     */
581    public static final String OS_ARCH = SystemProperties.getOsArch();
582
583    /**
584     * A constant for the System Property {@code os.name}. Operating system name.
585     *
586     * <p>
587     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
588     * </p>
589     * <p>
590     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
591     * called after this class is loaded, the value will be out of sync with that System property.
592     * </p>
593     *
594     * @see SystemProperties#getOsName()
595     * @since Java 1.1
596     */
597    public static final String OS_NAME = SystemProperties.getOsName();
598
599    /**
600     * A constant for the System Property {@code os.version}. Operating system version.
601     *
602     * <p>
603     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
604     * </p>
605     * <p>
606     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
607     * called after this class is loaded, the value will be out of sync with that System property.
608     * </p>
609     *
610     * @see SystemProperties#getOsVersion()
611     * @since Java 1.1
612     */
613    public static final String OS_VERSION = SystemProperties.getOsVersion();
614
615    /**
616     * A constant for the System Property {@code path.separator}. Path separator ({@code &quot;:&quot;} on Unix).
617     *
618     * <p>
619     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
620     * </p>
621     * <p>
622     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
623     * called after this class is loaded, the value will be out of sync with that System property.
624     * </p>
625     *
626     * @see SystemProperties#getPathSeparator()
627     * @deprecated Use {@link File#pathSeparator}, since it is guaranteed to be a string containing a single character and it does not require a privilege
628     *             check.
629     * @since Java 1.1
630     */
631    @Deprecated
632    public static final String PATH_SEPARATOR = SystemProperties.getPathSeparator();
633
634    /**
635     * A constant for the System Property {@code user.country} or {@code user.region}. User's country code, such as {@code "GB"}. First in Java version 1.2 as
636     * {@code user.region}. Renamed to {@code user.country} in 1.4
637     *
638     * <p>
639     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
640     * </p>
641     * <p>
642     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
643     * called after this class is loaded, the value will be out of sync with that System property.
644     * </p>
645     *
646     * @since 2.0
647     * @since Java 1.2
648     */
649    public static final String USER_COUNTRY = SystemProperties.getProperty(SystemProperties.USER_COUNTRY,
650            () -> SystemProperties.getProperty(SystemProperties.USER_REGION));
651
652    /**
653     * A constant for the System Property {@code user.dir}. User's current working directory.
654     *
655     * <p>
656     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
657     * </p>
658     * <p>
659     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
660     * called after this class is loaded, the value will be out of sync with that System property.
661     * </p>
662     *
663     * @see SystemProperties#getUserDir()
664     * @since Java 1.1
665     */
666    public static final String USER_DIR = SystemProperties.getUserDir();
667
668    /**
669     * A constant for the System Property {@code user.home}. User's home directory.
670     *
671     * <p>
672     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
673     * </p>
674     * <p>
675     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
676     * called after this class is loaded, the value will be out of sync with that System property.
677     * </p>
678     *
679     * @see SystemProperties#getUserHome()
680     * @since Java 1.1
681     */
682    public static final String USER_HOME = SystemProperties.getUserHome();
683
684    /**
685     * A constant for the System Property {@code user.language}. User's language code, such as {@code "en"}.
686     *
687     * <p>
688     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
689     * </p>
690     * <p>
691     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
692     * called after this class is loaded, the value will be out of sync with that System property.
693     * </p>
694     *
695     * @see SystemProperties#getUserLanguage()
696     * @since 2.0
697     * @since Java 1.2
698     */
699    public static final String USER_LANGUAGE = SystemProperties.getUserLanguage();
700
701    /**
702     * A constant for the System Property {@code user.name}. User's account name.
703     *
704     * <p>
705     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
706     * </p>
707     * <p>
708     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
709     * called after this class is loaded, the value will be out of sync with that System property.
710     * </p>
711     *
712     * @see SystemProperties#getUserName()
713     * @since Java 1.1
714     */
715    public static final String USER_NAME = SystemProperties.getUserName();
716
717    /**
718     * A constant for the System Property {@code user.timezone}. For example: {@code "America/Los_Angeles"}.
719     *
720     * <p>
721     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
722     * </p>
723     * <p>
724     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
725     * called after this class is loaded, the value will be out of sync with that System property.
726     * </p>
727     *
728     * @see SystemProperties#getUserTimezone()
729     * @since 2.1
730     */
731    public static final String USER_TIMEZONE = SystemProperties.getUserTimezone();
732
733    // Java version checks
734    // -----------------------------------------------------------------------
735    // These MUST be declared after those above as they depend on the
736    // values being set up
737
738    /**
739     * The constant {@code true} if this is Java version 1.1 (also 1.1.x versions).
740     * <p>
741     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
742     * </p>
743     * <p>
744     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
745     * </p>
746     * <p>
747     * This value is initialized when the class is loaded.
748     * </p>
749     */
750    public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");
751
752    /**
753     * The constant {@code true} if this is Java version 1.2 (also 1.2.x versions).
754     * <p>
755     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
756     * </p>
757     * <p>
758     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
759     * </p>
760     * <p>
761     * This value is initialized when the class is loaded.
762     * </p>
763     */
764    public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2");
765
766    /**
767     * The constant {@code true} if this is Java version 1.3 (also 1.3.x versions).
768     * <p>
769     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
770     * </p>
771     * <p>
772     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
773     * </p>
774     * <p>
775     * This value is initialized when the class is loaded.
776     * </p>
777     */
778    public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3");
779
780    /**
781     * The constant {@code true} if this is Java version 1.4 (also 1.4.x versions).
782     * <p>
783     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
784     * </p>
785     * <p>
786     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
787     * </p>
788     * <p>
789     * This value is initialized when the class is loaded.
790     * </p>
791     */
792    public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4");
793
794    /**
795     * The constant {@code true} if this is Java version 1.5 (also 1.5.x versions).
796     * <p>
797     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
798     * </p>
799     * <p>
800     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
801     * </p>
802     * <p>
803     * This value is initialized when the class is loaded.
804     * </p>
805     */
806    public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5");
807
808    /**
809     * The constant {@code true} if this is Java version 1.6 (also 1.6.x versions).
810     * <p>
811     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
812     * </p>
813     * <p>
814     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
815     * </p>
816     * <p>
817     * This value is initialized when the class is loaded.
818     * </p>
819     */
820    public static final boolean IS_JAVA_1_6 = getJavaVersionMatches("1.6");
821
822    /**
823     * The constant {@code true} if this is Java version 1.7 (also 1.7.x versions).
824     * <p>
825     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
826     * </p>
827     * <p>
828     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
829     * </p>
830     * <p>
831     * This value is initialized when the class is loaded.
832     * </p>
833     *
834     * @since 3.0
835     */
836    public static final boolean IS_JAVA_1_7 = getJavaVersionMatches("1.7");
837
838    /**
839     * The constant {@code true} if this is Java version 1.8 (also 1.8.x versions).
840     * <p>
841     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
842     * </p>
843     * <p>
844     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
845     * </p>
846     * <p>
847     * This value is initialized when the class is loaded.
848     * </p>
849     *
850     * @since 3.3.2
851     */
852    public static final boolean IS_JAVA_1_8 = getJavaVersionMatches("1.8");
853
854    /**
855     * The constant {@code true} if this is Java version 1.9 (also 1.9.x versions).
856     * <p>
857     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
858     * </p>
859     * <p>
860     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
861     * </p>
862     * <p>
863     * This value is initialized when the class is loaded.
864     * </p>
865     *
866     * @since 3.4
867     * @deprecated As of release 3.5, replaced by {@link #IS_JAVA_9}
868     */
869    @Deprecated
870    public static final boolean IS_JAVA_1_9 = getJavaVersionMatches("9");
871
872    /**
873     * The constant {@code true} if this is Java version 9 (also 9.x versions).
874     * <p>
875     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
876     * </p>
877     * <p>
878     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
879     * </p>
880     * <p>
881     * This value is initialized when the class is loaded.
882     * </p>
883     *
884     * @since 3.5
885     */
886    public static final boolean IS_JAVA_9 = getJavaVersionMatches("9");
887
888    /**
889     * The constant {@code true} if this is Java version 10 (also 10.x versions).
890     * <p>
891     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
892     * </p>
893     * <p>
894     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
895     * </p>
896     * <p>
897     * This value is initialized when the class is loaded.
898     * </p>
899     *
900     * @since 3.7
901     */
902    public static final boolean IS_JAVA_10 = getJavaVersionMatches("10");
903
904    /**
905     * The constant {@code true} if this is Java version 11 (also 11.x versions).
906     * <p>
907     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
908     * </p>
909     * <p>
910     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
911     * </p>
912     * <p>
913     * This value is initialized when the class is loaded.
914     * </p>
915     *
916     * @since 3.8
917     */
918    public static final boolean IS_JAVA_11 = getJavaVersionMatches("11");
919
920    /**
921     * The constant {@code true} if this is Java version 12 (also 12.x versions).
922     * <p>
923     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
924     * </p>
925     * <p>
926     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
927     * </p>
928     * <p>
929     * This value is initialized when the class is loaded.
930     * </p>
931     *
932     * @since 3.9
933     */
934    public static final boolean IS_JAVA_12 = getJavaVersionMatches("12");
935
936    /**
937     * The constant {@code true} if this is Java version 13 (also 13.x versions).
938     * <p>
939     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
940     * </p>
941     * <p>
942     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
943     * </p>
944     * <p>
945     * This value is initialized when the class is loaded.
946     * </p>
947     *
948     * @since 3.9
949     */
950    public static final boolean IS_JAVA_13 = getJavaVersionMatches("13");
951
952    /**
953     * The constant {@code true} if this is Java version 14 (also 14.x versions).
954     * <p>
955     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
956     * </p>
957     * <p>
958     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
959     * </p>
960     * <p>
961     * This value is initialized when the class is loaded.
962     * </p>
963     *
964     * @since 3.10
965     */
966    public static final boolean IS_JAVA_14 = getJavaVersionMatches("14");
967
968    /**
969     * The constant {@code true} if this is Java version 15 (also 15.x versions).
970     * <p>
971     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
972     * </p>
973     * <p>
974     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
975     * </p>
976     * <p>
977     * This value is initialized when the class is loaded.
978     * </p>
979     *
980     * @since 3.10
981     */
982    public static final boolean IS_JAVA_15 = getJavaVersionMatches("15");
983
984    /**
985     * The constant {@code true} if this is Java version 16 (also 16.x versions).
986     * <p>
987     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
988     * </p>
989     * <p>
990     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
991     * </p>
992     * <p>
993     * This value is initialized when the class is loaded.
994     * </p>
995     *
996     * @since 3.13.0
997     */
998    public static final boolean IS_JAVA_16 = getJavaVersionMatches("16");
999
1000    /**
1001     * The constant {@code true} if this is Java version 17 (also 17.x versions).
1002     * <p>
1003     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1004     * </p>
1005     * <p>
1006     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1007     * </p>
1008     * <p>
1009     * This value is initialized when the class is loaded.
1010     * </p>
1011     *
1012     * @since 3.13.0
1013     */
1014    public static final boolean IS_JAVA_17 = getJavaVersionMatches("17");
1015
1016    /**
1017     * The constant {@code true} if this is Java version 18 (also 18.x versions).
1018     * <p>
1019     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1020     * </p>
1021     * <p>
1022     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1023     * </p>
1024     * <p>
1025     * This value is initialized when the class is loaded.
1026     * </p>
1027     *
1028     * @since 3.13.0
1029     */
1030    public static final boolean IS_JAVA_18 = getJavaVersionMatches("18");
1031
1032    /**
1033     * The constant {@code true} if this is Java version 19 (also 19.x versions).
1034     * <p>
1035     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1036     * </p>
1037     * <p>
1038     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1039     * </p>
1040     * <p>
1041     * This value is initialized when the class is loaded.
1042     * </p>
1043     *
1044     * @since 3.13.0
1045     */
1046    public static final boolean IS_JAVA_19 = getJavaVersionMatches("19");
1047
1048    /**
1049     * The constant {@code true} if this is Java version 20 (also 20.x versions).
1050     * <p>
1051     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1052     * </p>
1053     * <p>
1054     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1055     * </p>
1056     * <p>
1057     * This value is initialized when the class is loaded.
1058     * </p>
1059     *
1060     * @since 3.13.0
1061     */
1062    public static final boolean IS_JAVA_20 = getJavaVersionMatches("20");
1063
1064    /**
1065     * The constant {@code true} if this is Java version 21 (also 21.x versions).
1066     * <p>
1067     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1068     * </p>
1069     * <p>
1070     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1071     * </p>
1072     * <p>
1073     * This value is initialized when the class is loaded.
1074     * </p>
1075     *
1076     * @since 3.13.0
1077     */
1078    public static final boolean IS_JAVA_21 = getJavaVersionMatches("21");
1079
1080    /**
1081     * The constant {@code true} if this is Java version 22 (also 22.x versions).
1082     * <p>
1083     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1084     * </p>
1085     * <p>
1086     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1087     * </p>
1088     * <p>
1089     * This value is initialized when the class is loaded.
1090     * </p>
1091     *
1092     * @since 3.15.0
1093     */
1094    public static final boolean IS_JAVA_22 = getJavaVersionMatches("22");
1095
1096    /**
1097     * The constant {@code true} if this is Java version 23 (also 23.x versions).
1098     * <p>
1099     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1100     * </p>
1101     * <p>
1102     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1103     * </p>
1104     * <p>
1105     * This value is initialized when the class is loaded.
1106     * </p>
1107     *
1108     * @since 3.18.0
1109     */
1110    public static final boolean IS_JAVA_23 = getJavaVersionMatches("23");
1111
1112    /**
1113     * The constant {@code true} if this is Java version 24 (also 24.x versions).
1114     * <p>
1115     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
1116     * </p>
1117     * <p>
1118     * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
1119     * </p>
1120     * <p>
1121     * This value is initialized when the class is loaded.
1122     * </p>
1123     *
1124     * @since 3.18.0
1125     */
1126    public static final boolean IS_JAVA_24 = getJavaVersionMatches("24");
1127
1128    // Operating system checks
1129    // -----------------------------------------------------------------------
1130    // These MUST be declared after those above as they depend on the
1131    // values being set up
1132    // Please advise dev@commons.apache.org if you want another added
1133    // or a mistake corrected
1134
1135    /**
1136     * The constant {@code true} if this is AIX.
1137     * <p>
1138     * The result depends on the value of the {@link #OS_NAME} constant.
1139     * </p>
1140     * <p>
1141     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1142     * </p>
1143     * <p>
1144     * This value is initialized when the class is loaded.
1145     * </p>
1146     *
1147     * @since 2.0
1148     */
1149    public static final boolean IS_OS_AIX = getOsNameMatches("AIX");
1150
1151    /**
1152     * The constant {@code true} if this is Android.
1153     *
1154     * <p>
1155     * See https://developer.android.com/reference/java/lang/System#getProperties().
1156     * </p>
1157     * <p>
1158     * This value is initialized when the class is loaded.
1159     * </p>
1160     *
1161     * @since 3.15.0
1162     */
1163    public static final boolean IS_OS_ANDROID = Strings.CS.contains(SystemProperties.getJavaVendor(), "Android");
1164
1165    /**
1166     * The constant {@code true} if this is HP-UX.
1167     * <p>
1168     * The result depends on the value of the {@link #OS_NAME} constant.
1169     * </p>
1170     * <p>
1171     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1172     * </p>
1173     * <p>
1174     * This value is initialized when the class is loaded.
1175     * </p>
1176     *
1177     * @since 2.0
1178     */
1179    public static final boolean IS_OS_HP_UX = getOsNameMatches("HP-UX");
1180
1181    /**
1182     * The constant {@code true} if this is IBM OS/400.
1183     * <p>
1184     * The result depends on the value of the {@link #OS_NAME} constant.
1185     * </p>
1186     * <p>
1187     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1188     * </p>
1189     * <p>
1190     * This value is initialized when the class is loaded.
1191     * </p>
1192     *
1193     * @since 3.3
1194     */
1195    public static final boolean IS_OS_400 = getOsNameMatches("OS/400");
1196
1197    /**
1198     * The constant {@code true} if this is Irix.
1199     * <p>
1200     * The result depends on the value of the {@link #OS_NAME} constant.
1201     * </p>
1202     * <p>
1203     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1204     * </p>
1205     * <p>
1206     * This value is initialized when the class is loaded.
1207     * </p>
1208     *
1209     * @since 2.0
1210     */
1211    public static final boolean IS_OS_IRIX = getOsNameMatches("Irix");
1212
1213    /**
1214     * The constant {@code true} if this is Linux.
1215     * <p>
1216     * The result depends on the value of the {@link #OS_NAME} constant.
1217     * </p>
1218     * <p>
1219     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1220     * </p>
1221     * <p>
1222     * This value is initialized when the class is loaded.
1223     * </p>
1224     *
1225     * @since 2.0
1226     */
1227    public static final boolean IS_OS_LINUX = getOsNameMatches("Linux");
1228
1229    /**
1230     * The constant {@code true} if this is Mac.
1231     * <p>
1232     * The result depends on the value of the {@link #OS_NAME} constant.
1233     * </p>
1234     * <p>
1235     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1236     * </p>
1237     * <p>
1238     * This value is initialized when the class is loaded.
1239     * </p>
1240     *
1241     * @since 2.0
1242     */
1243    public static final boolean IS_OS_MAC = getOsNameMatches("Mac");
1244
1245    /**
1246     * The constant {@code true} if this is Mac.
1247     * <p>
1248     * The result depends on the value of the {@link #OS_NAME} constant.
1249     * </p>
1250     * <p>
1251     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1252     * </p>
1253     * <p>
1254     * This value is initialized when the class is loaded.
1255     * </p>
1256     *
1257     * @since 2.0
1258     */
1259    public static final boolean IS_OS_MAC_OSX = getOsNameMatches("Mac OS X");
1260
1261    /**
1262     * The constant {@code true} if this is macOS X Cheetah.
1263     * <p>
1264     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1265     * </p>
1266     * <p>
1267     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1268     * </p>
1269     * <p>
1270     * This value is initialized when the class is loaded.
1271     * </p>
1272     *
1273     * @since 3.4
1274     */
1275    public static final boolean IS_OS_MAC_OSX_CHEETAH = getOsMatches("Mac OS X", "10.0");
1276
1277    /**
1278     * The constant {@code true} if this is macOS X Puma.
1279     * <p>
1280     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1281     * </p>
1282     * <p>
1283     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1284     * </p>
1285     * <p>
1286     * This value is initialized when the class is loaded.
1287     * </p>
1288     *
1289     * @since 3.4
1290     */
1291    public static final boolean IS_OS_MAC_OSX_PUMA = getOsMatches("Mac OS X", "10.1");
1292
1293    /**
1294     * The constant {@code true} if this is macOS X Jaguar.
1295     * <p>
1296     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1297     * </p>
1298     * <p>
1299     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1300     * </p>
1301     * <p>
1302     * This value is initialized when the class is loaded.
1303     * </p>
1304     *
1305     * @since 3.4
1306     */
1307    public static final boolean IS_OS_MAC_OSX_JAGUAR = getOsMatches("Mac OS X", "10.2");
1308
1309    /**
1310     * The constant {@code true} if this is macOS X Panther.
1311     * <p>
1312     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1313     * </p>
1314     * <p>
1315     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1316     * </p>
1317     * <p>
1318     * This value is initialized when the class is loaded.
1319     * </p>
1320     *
1321     * @since 3.4
1322     */
1323    public static final boolean IS_OS_MAC_OSX_PANTHER = getOsMatches("Mac OS X", "10.3");
1324
1325    /**
1326     * The constant {@code true} if this is macOS X Tiger.
1327     * <p>
1328     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1329     * </p>
1330     * <p>
1331     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1332     * </p>
1333     * <p>
1334     * This value is initialized when the class is loaded.
1335     * </p>
1336     *
1337     * @since 3.4
1338     */
1339    public static final boolean IS_OS_MAC_OSX_TIGER = getOsMatches("Mac OS X", "10.4");
1340
1341    /**
1342     * The constant {@code true} if this is macOS X Leopard.
1343     * <p>
1344     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1345     * </p>
1346     * <p>
1347     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1348     * </p>
1349     * <p>
1350     * This value is initialized when the class is loaded.
1351     * </p>
1352     *
1353     * @since 3.4
1354     */
1355    public static final boolean IS_OS_MAC_OSX_LEOPARD = getOsMatches("Mac OS X", "10.5");
1356
1357    /**
1358     * The constant {@code true} if this is macOS X Snow Leopard.
1359     * <p>
1360     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1361     * </p>
1362     * <p>
1363     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1364     * </p>
1365     * <p>
1366     * This value is initialized when the class is loaded.
1367     * </p>
1368     *
1369     * @since 3.4
1370     */
1371    public static final boolean IS_OS_MAC_OSX_SNOW_LEOPARD = getOsMatches("Mac OS X", "10.6");
1372
1373    /**
1374     * The constant {@code true} if this is macOS X Lion.
1375     * <p>
1376     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1377     * </p>
1378     * <p>
1379     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1380     * </p>
1381     * <p>
1382     * This value is initialized when the class is loaded.
1383     * </p>
1384     *
1385     * @since 3.4
1386     */
1387    public static final boolean IS_OS_MAC_OSX_LION = getOsMatches("Mac OS X", "10.7");
1388
1389    /**
1390     * The constant {@code true} if this is macOS X Mountain Lion.
1391     * <p>
1392     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1393     * </p>
1394     * <p>
1395     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1396     * </p>
1397     * <p>
1398     * This value is initialized when the class is loaded.
1399     * </p>
1400     *
1401     * @since 3.4
1402     */
1403    public static final boolean IS_OS_MAC_OSX_MOUNTAIN_LION = getOsMatches("Mac OS X", "10.8");
1404
1405    /**
1406     * The constant {@code true} if this is macOS X Mavericks.
1407     * <p>
1408     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1409     * </p>
1410     * <p>
1411     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1412     * </p>
1413     * <p>
1414     * This value is initialized when the class is loaded.
1415     * </p>
1416     *
1417     * @since 3.4
1418     */
1419    public static final boolean IS_OS_MAC_OSX_MAVERICKS = getOsMatches("Mac OS X", "10.9");
1420
1421    /**
1422     * The constant {@code true} if this is macOS X Yosemite.
1423     * <p>
1424     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1425     * </p>
1426     * <p>
1427     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1428     * </p>
1429     * <p>
1430     * This value is initialized when the class is loaded.
1431     * </p>
1432     *
1433     * @since 3.4
1434     */
1435    public static final boolean IS_OS_MAC_OSX_YOSEMITE = getOsMatches("Mac OS X", "10.10");
1436
1437    /**
1438     * The constant {@code true} if this is macOS X El Capitan.
1439     * <p>
1440     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1441     * </p>
1442     * <p>
1443     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1444     * </p>
1445     * <p>
1446     * This value is initialized when the class is loaded.
1447     * </p>
1448     *
1449     * @since 3.5
1450     */
1451    public static final boolean IS_OS_MAC_OSX_EL_CAPITAN = getOsMatches("Mac OS X", "10.11");
1452
1453    /**
1454     * The constant {@code true} if this is macOS X Sierra.
1455     * <p>
1456     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1457     * </p>
1458     * <p>
1459     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1460     * </p>
1461     * <p>
1462     * This value is initialized when the class is loaded.
1463     * </p>
1464     *
1465     * @since 3.12.0
1466     */
1467    public static final boolean IS_OS_MAC_OSX_SIERRA = getOsMatches("Mac OS X", "10.12");
1468
1469    /**
1470     * The constant {@code true} if this is macOS X High Sierra.
1471     * <p>
1472     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1473     * </p>
1474     * <p>
1475     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1476     * </p>
1477     * <p>
1478     * This value is initialized when the class is loaded.
1479     * </p>
1480     *
1481     * @since 3.12.0
1482     */
1483    public static final boolean IS_OS_MAC_OSX_HIGH_SIERRA = getOsMatches("Mac OS X", "10.13");
1484
1485    /**
1486     * The constant {@code true} if this is macOS X Mojave.
1487     * <p>
1488     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1489     * </p>
1490     * <p>
1491     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1492     * </p>
1493     * <p>
1494     * This value is initialized when the class is loaded.
1495     * </p>
1496     *
1497     * @since 3.12.0
1498     */
1499    public static final boolean IS_OS_MAC_OSX_MOJAVE = getOsMatches("Mac OS X", "10.14");
1500
1501    /**
1502     * The constant {@code true} if this is macOS X Catalina.
1503     *
1504     * <p>
1505     * The field will return {@code false} if {@code OS_NAME} is {@code null}.
1506     * </p>
1507     * <p>
1508     * This value is initialized when the class is loaded.
1509     * </p>
1510     *
1511     * @since 3.12.0
1512     */
1513    public static final boolean IS_OS_MAC_OSX_CATALINA = getOsMatches("Mac OS X", "10.15");
1514
1515    /**
1516     * The constant {@code true} if this is macOS X Big Sur.
1517     * <p>
1518     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1519     * </p>
1520     * <p>
1521     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1522     * </p>
1523     * <p>
1524     * This value is initialized when the class is loaded.
1525     * </p>
1526     *
1527     * @since 3.12.0
1528     */
1529    public static final boolean IS_OS_MAC_OSX_BIG_SUR = getOsMatches("Mac OS X", "11");
1530
1531    /**
1532     * The constant {@code true} if this is macOS X Monterey.
1533     * <p>
1534     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1535     * </p>
1536     * <p>
1537     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1538     * </p>
1539     * <p>
1540     * This value is initialized when the class is loaded.
1541     * </p>
1542     *
1543     * @since 3.13.0
1544     */
1545    public static final boolean IS_OS_MAC_OSX_MONTEREY = getOsMatches("Mac OS X", "12");
1546
1547    /**
1548     * The constant {@code true} if this is macOS X Ventura.
1549     * <p>
1550     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1551     * </p>
1552     * <p>
1553     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1554     * </p>
1555     * <p>
1556     * This value is initialized when the class is loaded.
1557     * </p>
1558     *
1559     * @since 3.13.0
1560     */
1561    public static final boolean IS_OS_MAC_OSX_VENTURA = getOsMatches("Mac OS X", "13");
1562
1563    /**
1564     * The constant {@code true} if this is macOS X Sonoma.
1565     * <p>
1566     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1567     * </p>
1568     * <p>
1569     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1570     * </p>
1571     * <p>
1572     * This value is initialized when the class is loaded.
1573     * </p>
1574     *
1575     * @since 3.15.0
1576     */
1577    public static final boolean IS_OS_MAC_OSX_SONOMA = getOsMatches("Mac OS X", "14");
1578
1579    /**
1580     * The constant {@code true} if this is macOS X Sequoia.
1581     * <p>
1582     * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
1583     * </p>
1584     * <p>
1585     * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
1586     * </p>
1587     * <p>
1588     * This value is initialized when the class is loaded.
1589     * </p>
1590     *
1591     * @since 3.18.0
1592     */
1593    public static final boolean IS_OS_MAC_OSX_SEQUOIA = getOsMatches("Mac OS X", "15");
1594
1595    /**
1596     * The constant {@code true} if this is FreeBSD.
1597     * <p>
1598     * The result depends on the value of the {@link #OS_NAME} constant.
1599     * </p>
1600     * <p>
1601     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1602     * </p>
1603     * <p>
1604     * This value is initialized when the class is loaded.
1605     * </p>
1606     *
1607     * @since 3.1
1608     */
1609    public static final boolean IS_OS_FREE_BSD = getOsNameMatches("FreeBSD");
1610
1611    /**
1612     * The constant {@code true} if this is OpenBSD.
1613     * <p>
1614     * The result depends on the value of the {@link #OS_NAME} constant.
1615     * </p>
1616     * <p>
1617     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1618     * </p>
1619     * <p>
1620     * This value is initialized when the class is loaded.
1621     * </p>
1622     *
1623     * @since 3.1
1624     */
1625    public static final boolean IS_OS_OPEN_BSD = getOsNameMatches("OpenBSD");
1626
1627    /**
1628     * The constant {@code true} if this is NetBSD.
1629     * <p>
1630     * The result depends on the value of the {@link #OS_NAME} constant.
1631     * </p>
1632     * <p>
1633     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1634     * </p>
1635     * <p>
1636     * This value is initialized when the class is loaded.
1637     * </p>
1638     *
1639     * @since 3.1
1640     */
1641    public static final boolean IS_OS_NET_BSD = getOsNameMatches("NetBSD");
1642
1643    /**
1644     * The constant {@code true} if this is Netware.
1645     * <p>
1646     * The result depends on the value of the {@link #OS_NAME} constant.
1647     * </p>
1648     * <p>
1649     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1650     * </p>
1651     * <p>
1652     * This value is initialized when the class is loaded.
1653     * </p>
1654     *
1655     * @since 3.19.0
1656     */
1657    public static final boolean IS_OS_NETWARE = getOsNameMatches("Netware");
1658
1659    /**
1660     * The constant {@code true} if this is OS/2.
1661     * <p>
1662     * The result depends on the value of the {@link #OS_NAME} constant.
1663     * </p>
1664     * <p>
1665     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1666     * </p>
1667     * <p>
1668     * This value is initialized when the class is loaded.
1669     * </p>
1670     *
1671     * @since 2.0
1672     */
1673    public static final boolean IS_OS_OS2 = getOsNameMatches("OS/2");
1674
1675    /**
1676     * The constant {@code true} if this is Solaris.
1677     * <p>
1678     * The result depends on the value of the {@link #OS_NAME} constant.
1679     * </p>
1680     * <p>
1681     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1682     * </p>
1683     * <p>
1684     * This value is initialized when the class is loaded.
1685     * </p>
1686     *
1687     * @since 2.0
1688     */
1689    public static final boolean IS_OS_SOLARIS = getOsNameMatches("Solaris");
1690
1691    /**
1692     * The constant {@code true} if this is SunOS.
1693     * <p>
1694     * The result depends on the value of the {@link #OS_NAME} constant.
1695     * </p>
1696     * <p>
1697     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1698     * </p>
1699     * <p>
1700     * This value is initialized when the class is loaded.
1701     * </p>
1702     *
1703     * @since 2.0
1704     */
1705    public static final boolean IS_OS_SUN_OS = getOsNameMatches("SunOS");
1706
1707    /**
1708     * The constant {@code true} if this is a Unix like system, as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.
1709     *
1710     * <p>
1711     * The field will return {@code false} if {@code OS_NAME} is {@code null}.
1712     * </p>
1713     * <p>
1714     * This value is initialized when the class is loaded.
1715     * </p>
1716     *
1717     * @since 2.1
1718     */
1719    public static final boolean IS_OS_UNIX = IS_OS_AIX || IS_OS_HP_UX || IS_OS_IRIX || IS_OS_LINUX || IS_OS_MAC_OSX || IS_OS_SOLARIS || IS_OS_SUN_OS
1720            || IS_OS_FREE_BSD || IS_OS_OPEN_BSD || IS_OS_NET_BSD;
1721
1722    /**
1723     * The constant {@code true} if this is Windows.
1724     * <p>
1725     * The result depends on the value of the {@link #OS_NAME} constant.
1726     * </p>
1727     * <p>
1728     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1729     * </p>
1730     * <p>
1731     * This value is initialized when the class is loaded.
1732     * </p>
1733     *
1734     * @since 2.0
1735     */
1736    public static final boolean IS_OS_WINDOWS = getOsNameMatches(OS_NAME_WINDOWS_PREFIX);
1737
1738    /**
1739     * The constant {@code true} if this is Windows 2000.
1740     * <p>
1741     * The result depends on the value of the {@link #OS_NAME} constant.
1742     * </p>
1743     * <p>
1744     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1745     * </p>
1746     * <p>
1747     * This value is initialized when the class is loaded.
1748     * </p>
1749     *
1750     * @since 2.0
1751     */
1752    public static final boolean IS_OS_WINDOWS_2000 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 2000");
1753
1754    /**
1755     * The constant {@code true} if this is Windows 2003.
1756     * <p>
1757     * The result depends on the value of the {@link #OS_NAME} constant.
1758     * </p>
1759     * <p>
1760     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1761     * </p>
1762     * <p>
1763     * This value is initialized when the class is loaded.
1764     * </p>
1765     *
1766     * @since 3.1
1767     */
1768    public static final boolean IS_OS_WINDOWS_2003 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 2003");
1769
1770    /**
1771     * The constant {@code true} if this is Windows Server 2008.
1772     * <p>
1773     * The result depends on the value of the {@link #OS_NAME} constant.
1774     * </p>
1775     * <p>
1776     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1777     * </p>
1778     * <p>
1779     * This value is initialized when the class is loaded.
1780     * </p>
1781     *
1782     * @since 3.1
1783     */
1784    public static final boolean IS_OS_WINDOWS_2008 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Server 2008");
1785
1786    /**
1787     * The constant {@code true} if this is Windows Server 2012.
1788     * <p>
1789     * The result depends on the value of the {@link #OS_NAME} constant.
1790     * </p>
1791     * <p>
1792     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1793     * </p>
1794     * <p>
1795     * This value is initialized when the class is loaded.
1796     * </p>
1797     *
1798     * @since 3.4
1799     */
1800    public static final boolean IS_OS_WINDOWS_2012 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Server 2012");
1801
1802    /**
1803     * The constant {@code true} if this is Windows 95.
1804     * <p>
1805     * The result depends on the value of the {@link #OS_NAME} constant.
1806     * </p>
1807     * <p>
1808     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1809     * </p>
1810     * <p>
1811     * This value is initialized when the class is loaded.
1812     * </p>
1813     *
1814     * @since 2.0
1815     */
1816    public static final boolean IS_OS_WINDOWS_95 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 95");
1817
1818    /**
1819     * The constant {@code true} if this is Windows 98.
1820     * <p>
1821     * The result depends on the value of the {@link #OS_NAME} constant.
1822     * </p>
1823     * <p>
1824     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1825     * </p>
1826     * <p>
1827     * This value is initialized when the class is loaded.
1828     * </p>
1829     *
1830     * @since 2.0
1831     */
1832    public static final boolean IS_OS_WINDOWS_98 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 98");
1833
1834    /**
1835     * The constant {@code true} if this is Windows ME.
1836     * <p>
1837     * The result depends on the value of the {@link #OS_NAME} constant.
1838     * </p>
1839     * <p>
1840     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1841     * </p>
1842     * <p>
1843     * This value is initialized when the class is loaded.
1844     * </p>
1845     *
1846     * @since 2.0
1847     */
1848    public static final boolean IS_OS_WINDOWS_ME = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Me");
1849
1850    /**
1851     * The constant {@code true} if this is Windows NT.
1852     * <p>
1853     * The result depends on the value of the {@link #OS_NAME} constant.
1854     * </p>
1855     * <p>
1856     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1857     * </p>
1858     * <p>
1859     * This value is initialized when the class is loaded.
1860     * </p>
1861     *
1862     * @since 2.0
1863     */
1864    public static final boolean IS_OS_WINDOWS_NT = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " NT");
1865
1866    /**
1867     * The constant {@code true} if this is Windows XP.
1868     * <p>
1869     * The result depends on the value of the {@link #OS_NAME} constant.
1870     * </p>
1871     * <p>
1872     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1873     * </p>
1874     * <p>
1875     * This value is initialized when the class is loaded.
1876     * </p>
1877     *
1878     * @since 2.0
1879     */
1880    public static final boolean IS_OS_WINDOWS_XP = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " XP");
1881
1882    /**
1883     * The constant {@code true} if this is Windows Vista.
1884     * <p>
1885     * The result depends on the value of the {@link #OS_NAME} constant.
1886     * </p>
1887     * <p>
1888     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1889     * </p>
1890     * <p>
1891     * This value is initialized when the class is loaded.
1892     * </p>
1893     *
1894     * @since 2.4
1895     */
1896    public static final boolean IS_OS_WINDOWS_VISTA = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Vista");
1897
1898    /**
1899     * The constant {@code true} if this is Windows 7.
1900     * <p>
1901     * The result depends on the value of the {@link #OS_NAME} constant.
1902     * </p>
1903     * <p>
1904     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1905     * </p>
1906     * <p>
1907     * This value is initialized when the class is loaded.
1908     * </p>
1909     *
1910     * @since 3.0
1911     */
1912    public static final boolean IS_OS_WINDOWS_7 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 7");
1913
1914    /**
1915     * The constant {@code true} if this is Windows 8.
1916     * <p>
1917     * The result depends on the value of the {@link #OS_NAME} constant.
1918     * </p>
1919     * <p>
1920     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1921     * </p>
1922     * <p>
1923     * This value is initialized when the class is loaded.
1924     * </p>
1925     *
1926     * @since 3.2
1927     */
1928    public static final boolean IS_OS_WINDOWS_8 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 8");
1929
1930    /**
1931     * The constant {@code true} if this is Windows 10.
1932     * <p>
1933     * The result depends on the value of the {@link #OS_NAME} constant.
1934     * </p>
1935     * <p>
1936     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1937     * </p>
1938     * <p>
1939     * This value is initialized when the class is loaded.
1940     * </p>
1941     *
1942     * @since 3.5
1943     */
1944    public static final boolean IS_OS_WINDOWS_10 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 10");
1945
1946    /**
1947     * The constant {@code true} if this is Windows 11.
1948     * <p>
1949     * The result depends on the value of the {@link #OS_NAME} constant.
1950     * </p>
1951     * <p>
1952     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1953     * </p>
1954     * <p>
1955     * OpenJDK fixed the return value for {@code os.name} on Windows 11 to versions 8, 11, and 17:
1956     * </p>
1957     * <ul>
1958     * <li>Affects Java versions 7u321, 8u311, 11.0.13-oracle, 17.0.1: https://bugs.openjdk.org/browse/JDK-8274737</li>
1959     * <li>Fixed in OpenJDK commit https://github.com/openjdk/jdk/commit/97ea9dd2f24f9f1fb9b9345a4202a825ee28e014</li>
1960     * </ul>
1961     * <p>
1962     * This value is initialized when the class is loaded.
1963     * </p>
1964     *
1965     * @since 3.13.0
1966     */
1967    public static final boolean IS_OS_WINDOWS_11 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 11");
1968
1969    /**
1970     * The constant {@code true} if this is z/OS.
1971     * <p>
1972     * The result depends on the value of the {@link #OS_NAME} constant.
1973     * </p>
1974     * <p>
1975     * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
1976     * </p>
1977     * <p>
1978     * This value is initialized when the class is loaded.
1979     * </p>
1980     *
1981     * @since 3.5
1982     */
1983    // Values on a z/OS system I tested (Gary Gregory - 2016-03-12)
1984    // os.arch = s390x
1985    // os.encoding = ISO8859_1
1986    // os.name = z/OS
1987    // os.version = 02.02.00
1988    public static final boolean IS_OS_ZOS = getOsNameMatches("z/OS");
1989
1990    /**
1991     * The System property key for the user home directory.
1992     */
1993    public static final String USER_HOME_KEY = "user.home";
1994
1995    /**
1996     * The System property key for the user name.
1997     *
1998     * @deprecated Use {@link SystemProperties#USER_NAME}.
1999     */
2000    @Deprecated
2001    public static final String USER_NAME_KEY = "user.name";
2002
2003    /**
2004     * The System property key for the user directory.
2005     *
2006     * @deprecated Use {@link SystemProperties#USER_DIR}.
2007     */
2008    @Deprecated
2009    public static final String USER_DIR_KEY = "user.dir";
2010
2011    /**
2012     * The System property key for the Java IO temporary directory.
2013     *
2014     * @deprecated Use {@link SystemProperties#JAVA_IO_TMPDIR}.
2015     */
2016    @Deprecated
2017    public static final String JAVA_IO_TMPDIR_KEY = "java.io.tmpdir";
2018
2019    /**
2020     * The System property key for the Java home directory.
2021     *
2022     * @deprecated Use {@link SystemProperties#JAVA_HOME}.
2023     */
2024    @Deprecated
2025    public static final String JAVA_HOME_KEY = "java.home";
2026
2027    /**
2028     * A constant for the System Property {@code awt.toolkit}.
2029     *
2030     * <p>
2031     * Holds a class name, on Windows XP this is {@code sun.awt.windows.WToolkit}.
2032     * </p>
2033     * <p>
2034     * <strong>On platforms without a GUI, this value is {@code null}.</strong>
2035     * </p>
2036     * <p>
2037     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
2038     * </p>
2039     * <p>
2040     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
2041     * called after this class is loaded, the value will be out of sync with that System property.
2042     * </p>
2043     *
2044     * @since 2.1
2045     * @see SystemProperties#getAwtToolkit()
2046     */
2047    public static final String AWT_TOOLKIT = SystemProperties.getAwtToolkit();
2048
2049    /**
2050     * Gets an environment variable, defaulting to {@code defaultValue} if the variable cannot be read.
2051     *
2052     * <p>
2053     * If a {@link SecurityException} is caught, the return value is {@code defaultValue} and a message is written to {@code System.err}.
2054     * </p>
2055     *
2056     * @param name         the environment variable name.
2057     * @param defaultValue the default value.
2058     * @return the environment variable value or {@code defaultValue} if a security problem occurs.
2059     * @since 3.8
2060     */
2061    public static String getEnvironmentVariable(final String name, final String defaultValue) {
2062        try {
2063            final String value = System.getenv(name);
2064            return value == null ? defaultValue : value;
2065        } catch (final SecurityException ex) {
2066            // we are not allowed to look at this property
2067            // System.err.println("Caught a SecurityException reading the environment variable '" + name + "'.");
2068            return defaultValue;
2069        }
2070    }
2071
2072    /**
2073     * Gets the host name from an environment variable ({@code COMPUTERNAME} on Windows, {@code HOSTNAME} elsewhere).
2074     *
2075     * <p>
2076     * If you want to know what the network stack says is the host name, you should use {@code InetAddress.getLocalHost().getHostName()}.
2077     * </p>
2078     *
2079     * @return the host name. Will be {@code null} if the environment variable is not defined.
2080     * @since 3.6
2081     */
2082    public static String getHostName() {
2083        return IS_OS_WINDOWS ? System.getenv("COMPUTERNAME") : System.getenv("HOSTNAME");
2084    }
2085
2086    /**
2087     * Gets the current Java home directory as a {@link File}.
2088     *
2089     * @return a directory.
2090     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2091     * @see SystemProperties#getJavaHome()
2092     * @since 2.1
2093     */
2094    public static File getJavaHome() {
2095        return new File(SystemProperties.getJavaHome());
2096    }
2097
2098    /**
2099     * Gets the current Java home directory as a {@link File}.
2100     *
2101     * @return a directory.
2102     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2103     * @see SystemProperties#getJavaHome()
2104     * @since 3.18.0
2105     */
2106    public static Path getJavaHomePath() {
2107        return Paths.get(SystemProperties.getJavaHome());
2108    }
2109
2110    /**
2111     * Gets the current Java IO temporary directory as a {@link File}.
2112     *
2113     * @return a directory.
2114     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2115     * @see SystemProperties#getJavaIoTmpdir()
2116     * @since 2.1
2117     */
2118    public static File getJavaIoTmpDir() {
2119        return new File(SystemProperties.getJavaIoTmpdir());
2120    }
2121
2122    /**
2123     * Gets the current Java IO temporary directory as a {@link Path}.
2124     *
2125     * @return a directory.
2126     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2127     * @see SystemProperties#getJavaIoTmpdir()
2128     * @since 3.18.0
2129     */
2130    public static Path getJavaIoTmpDirPath() {
2131        return Paths.get(SystemProperties.getJavaIoTmpdir());
2132    }
2133
2134    /**
2135     * Tests if the Java version matches the version we are running.
2136     * <p>
2137     * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
2138     * </p>
2139     *
2140     * @param versionPrefix the prefix for the Java version.
2141     * @return true if matches, or false if not or can't determine.
2142     */
2143    private static boolean getJavaVersionMatches(final String versionPrefix) {
2144        return isJavaVersionMatch(JAVA_SPECIFICATION_VERSION, versionPrefix);
2145    }
2146
2147    /**
2148     * Tests if the operating system matches the given name prefix and version prefix.
2149     * <p>
2150     * The result depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
2151     * </p>
2152     * <p>
2153     * The method returns {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
2154     * </p>
2155     *
2156     * @param osNamePrefix    the prefix for the OS name.
2157     * @param osVersionPrefix the prefix for the version.
2158     * @return true if matches, or false if not or can't determine.
2159     */
2160    private static boolean getOsMatches(final String osNamePrefix, final String osVersionPrefix) {
2161        return isOsMatch(OS_NAME, OS_VERSION, osNamePrefix, osVersionPrefix);
2162    }
2163
2164    /**
2165     * Tests if the operating system matches the given string with a case-insensitive comparison.
2166     * <p>
2167     * The result depends on the value of the {@link #OS_NAME} constant.
2168     * </p>
2169     * <p>
2170     * The method returns {@code false} if {@link #OS_NAME} is {@code null}.
2171     * </p>
2172     *
2173     * @param osNamePrefix the prefix for the OS name.
2174     * @return true if matches, or false if not or can't determine.
2175     */
2176    private static boolean getOsNameMatches(final String osNamePrefix) {
2177        return isOsNameMatch(OS_NAME, osNamePrefix);
2178    }
2179
2180    /**
2181     * Gets the current user directory as a {@link File}.
2182     * <p>
2183     * The result is based on the system property {@value SystemProperties#USER_DIR}.
2184     * </p>
2185     *
2186     * @return a directory.
2187     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2188     * @see SystemProperties#getUserDir()
2189     * @since 2.1
2190     */
2191    public static File getUserDir() {
2192        return new File(SystemProperties.getUserDir());
2193    }
2194
2195    /**
2196     * Gets the current user directory as a {@link Path}.
2197     * <p>
2198     * The result is based on the system property {@value SystemProperties#USER_DIR}.
2199     * </p>
2200     *
2201     * @return a directory.
2202     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2203     * @see SystemProperties#getUserDir()
2204     * @since 3.18.0
2205     */
2206    public static Path getUserDirPath() {
2207        return Paths.get(SystemProperties.getUserDir());
2208    }
2209
2210    /**
2211     * Gets the current user home directory as a {@link File}.
2212     * <p>
2213     * The result is based on the system property {@value SystemProperties#USER_HOME}.
2214     * </p>
2215     *
2216     * @return a directory.
2217     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2218     * @see SystemProperties#getUserHome()
2219     * @since 2.1
2220     */
2221    public static File getUserHome() {
2222        return new File(SystemProperties.getUserHome());
2223    }
2224
2225    /**
2226     * Gets the current user home directory as a {@link Path}.
2227     * <p>
2228     * The result is based on the system property {@value SystemProperties#USER_HOME}.
2229     * </p>
2230     *
2231     * @return a directory.
2232     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2233     * @see SystemProperties#getUserHome()
2234     * @since 3.18.0
2235     */
2236    public static Path getUserHomePath() {
2237        return Paths.get(SystemProperties.getUserHome());
2238    }
2239
2240    /**
2241     * Gets the current user name.
2242     * <p>
2243     * The result is based on the system property {@value SystemProperties#USER_NAME}.
2244     * </p>
2245     *
2246     * @return a name.
2247     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2248     * @see SystemProperties#getUserName()
2249     * @since 3.10
2250     * @deprecated Use {@link SystemProperties#getUserName()}.
2251     */
2252    @Deprecated
2253    public static String getUserName() {
2254        return SystemProperties.getUserName();
2255    }
2256
2257    /**
2258     * Gets the user name.
2259     * <p>
2260     * The result is based on the system property {@value SystemProperties#USER_NAME}.
2261     * </p>
2262     *
2263     * @param defaultValue A default value.
2264     * @return a name.
2265     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
2266     * @see SystemProperties#getUserName()
2267     * @since 3.10
2268     * @deprecated Use {@link SystemProperties#getUserName(String)}.
2269     */
2270    @Deprecated
2271    public static String getUserName(final String defaultValue) {
2272        return SystemProperties.getUserName(defaultValue);
2273    }
2274
2275    /**
2276     * Tests whether the {@link #JAVA_AWT_HEADLESS} value is {@code true}.
2277     * <p>
2278     * The result is based on the system property {@value SystemProperties#JAVA_AWT_HEADLESS}.
2279     * </p>
2280     *
2281     * @return {@code true} if {@code JAVA_AWT_HEADLESS} is {@code "true"}, {@code false} otherwise.
2282     * @see #JAVA_AWT_HEADLESS
2283     * @since 2.1
2284     * @since Java 1.4
2285     */
2286    public static boolean isJavaAwtHeadless() {
2287        return Boolean.TRUE.toString().equals(JAVA_AWT_HEADLESS);
2288    }
2289
2290    /**
2291     * Tests whether the Java version at least the requested version.
2292     * <p>
2293     * The result is based on the system property saved in {@link #JAVA_SPECIFICATION_VERSION}.
2294     * </p>
2295     *
2296     * @param requiredVersion the required version, for example 1.31f.
2297     * @return {@code true} if the actual version is equal or greater than the required version.
2298     */
2299    public static boolean isJavaVersionAtLeast(final JavaVersion requiredVersion) {
2300        return JAVA_SPECIFICATION_VERSION_AS_ENUM != null && JAVA_SPECIFICATION_VERSION_AS_ENUM.atLeast(requiredVersion);
2301    }
2302
2303    /**
2304     * Tests whether the Java version at most the requested version.
2305     * <p>
2306     * The result is based on the system property saved in {@link #JAVA_SPECIFICATION_VERSION}.
2307     * </p>
2308     *
2309     * @param requiredVersion the required version, for example 1.31f.
2310     * @return {@code true} if the actual version is equal or less than the required version.
2311     * @since 3.9
2312     */
2313    public static boolean isJavaVersionAtMost(final JavaVersion requiredVersion) {
2314        return JAVA_SPECIFICATION_VERSION_AS_ENUM != null && JAVA_SPECIFICATION_VERSION_AS_ENUM.atMost(requiredVersion);
2315    }
2316
2317    /**
2318     * Tests whether the Java version matches.
2319     *
2320     * <p>
2321     * This method is package private instead of private to support unit test invocation.
2322     * </p>
2323     *
2324     * @param version       the actual Java version.
2325     * @param versionPrefix the prefix for the expected Java version.
2326     * @return true if matches, or false if not or can't determine.
2327     */
2328    static boolean isJavaVersionMatch(final String version, final String versionPrefix) {
2329        if (version == null) {
2330            return false;
2331        }
2332        return version.startsWith(versionPrefix);
2333    }
2334
2335    /**
2336     * Tests whether the operating system matches.
2337     * <p>
2338     * This method is package private instead of private to support unit test invocation.
2339     * </p>
2340     *
2341     * @param osName          the actual OS name.
2342     * @param osVersion       the actual OS version.
2343     * @param osNamePrefix    the prefix for the expected OS name.
2344     * @param osVersionPrefix the prefix for the expected OS version.
2345     * @return true if matches, or false if not or can't determine.
2346     */
2347    static boolean isOsMatch(final String osName, final String osVersion, final String osNamePrefix, final String osVersionPrefix) {
2348        if (osName == null || osVersion == null) {
2349            return false;
2350        }
2351        return isOsNameMatch(osName, osNamePrefix) && isOsVersionMatch(osVersion, osVersionPrefix);
2352    }
2353
2354    /**
2355     * Tests whether the operating system matches with a case-insensitive comparison.
2356     * <p>
2357     * This method is package private instead of private to support unit test invocation.
2358     * </p>
2359     *
2360     * @param osName       the actual OS name.
2361     * @param osNamePrefix the prefix for the expected OS name.
2362     * @return true for a case-insensitive match, or false if not.
2363     */
2364    static boolean isOsNameMatch(final String osName, final String osNamePrefix) {
2365        if (osName == null) {
2366            return false;
2367        }
2368        return Strings.CI.startsWith(osName, osNamePrefix);
2369    }
2370
2371    /**
2372     * Tests whether the operating system version matches.
2373     * <p>
2374     * This method is package private instead of private to support unit test invocation.
2375     * </p>
2376     *
2377     * @param osVersion       the actual OS version.
2378     * @param osVersionPrefix the prefix for the expected OS version.
2379     * @return true if matches, or false if not or can't determine.
2380     */
2381    static boolean isOsVersionMatch(final String osVersion, final String osVersionPrefix) {
2382        if (StringUtils.isEmpty(osVersion)) {
2383            return false;
2384        }
2385        // Compare parts of the version string instead of using String.startsWith(String) because otherwise
2386        // osVersionPrefix 10.1 would also match osVersion 10.10
2387        final String[] versionPrefixParts = JavaVersion.split(osVersionPrefix);
2388        final String[] versionParts = JavaVersion.split(osVersion);
2389        for (int i = 0; i < Math.min(versionPrefixParts.length, versionParts.length); i++) {
2390            if (!versionPrefixParts[i].equals(versionParts[i])) {
2391                return false;
2392            }
2393        }
2394        return true;
2395    }
2396
2397    /**
2398     * SystemUtils instances shouldn't be constructed in standard programming. Instead, elements should be accessed directly, for example
2399     * {@code SystemUtils.FILE_SEPARATOR}.
2400     *
2401     * <p>
2402     * This constructor is public to permit tools that require a JavaBean instance to operate.
2403     * </p>
2404     */
2405    public SystemUtils() {
2406    }
2407
2408}