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