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