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