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