565 566 private static Properties props; 567 private static native Properties initProperties(Properties props); 568 569 /** 570 * Determines the current system properties. 571 * <p> 572 * First, if there is a security manager, its 573 * <code>checkPropertiesAccess</code> method is called with no 574 * arguments. This may result in a security exception. 575 * <p> 576 * The current set of system properties for use by the 577 * {@link #getProperty(String)} method is returned as a 578 * <code>Properties</code> object. If there is no current set of 579 * system properties, a set of system properties is first created and 580 * initialized. This set of system properties always includes values 581 * for the following keys: 582 * <table class="striped"> 583 * <caption style="display:none">Shows property keys and associated values</caption> 584 * <thead> 585 * <tr><th>Key</th> 586 * <th>Description of Associated Value</th></tr> 587 * </thead> 588 * <tbody> 589 * <tr><td><code>java.version</code></td> 590 * <td>Java Runtime Environment version which may be interpreted 591 * as a {@link Runtime.Version}</td></tr> 592 * <tr><td><code>java.vendor</code></td> 593 * <td>Java Runtime Environment vendor</td></tr> 594 * <tr><td><code>java.vendor.url</code></td> 595 * <td>Java vendor URL</td></tr> 596 * <tr><td><code>java.home</code></td> 597 * <td>Java installation directory</td></tr> 598 * <tr><td><code>java.vm.specification.version</code></td> 599 * <td>Java Virtual Machine specification version which may be 600 * interpreted as a {@link Runtime.Version}</td></tr> 601 * <tr><td><code>java.vm.specification.vendor</code></td> 602 * <td>Java Virtual Machine specification vendor</td></tr> 603 * <tr><td><code>java.vm.specification.name</code></td> 604 * <td>Java Virtual Machine specification name</td></tr> 605 * <tr><td><code>java.vm.version</code></td> 606 * <td>Java Virtual Machine implementation version which may be 607 * interpreted as a {@link Runtime.Version}</td></tr> 608 * <tr><td><code>java.vm.vendor</code></td> 609 * <td>Java Virtual Machine implementation vendor</td></tr> 610 * <tr><td><code>java.vm.name</code></td> 611 * <td>Java Virtual Machine implementation name</td></tr> 612 * <tr><td><code>java.specification.version</code></td> 613 * <td>Java Runtime Environment specification version which may be 614 * interpreted as a {@link Runtime.Version}</td></tr> 615 * <tr><td><code>java.specification.vendor</code></td> 616 * <td>Java Runtime Environment specification vendor</td></tr> 617 * <tr><td><code>java.specification.name</code></td> 618 * <td>Java Runtime Environment specification name</td></tr> 619 * <tr><td><code>java.class.version</code></td> 620 * <td>Java class format version number</td></tr> 621 * <tr><td><code>java.class.path</code></td> 622 * <td>Java class path</td></tr> 623 * <tr><td><code>java.library.path</code></td> 624 * <td>List of paths to search when loading libraries</td></tr> 625 * <tr><td><code>java.io.tmpdir</code></td> 626 * <td>Default temp file path</td></tr> 627 * <tr><td><code>java.compiler</code></td> 628 * <td>Name of JIT compiler to use</td></tr> 629 * <tr><td><code>os.name</code></td> 630 * <td>Operating system name</td></tr> 631 * <tr><td><code>os.arch</code></td> 632 * <td>Operating system architecture</td></tr> 633 * <tr><td><code>os.version</code></td> 634 * <td>Operating system version</td></tr> 635 * <tr><td><code>file.separator</code></td> 636 * <td>File separator ("/" on UNIX)</td></tr> 637 * <tr><td><code>path.separator</code></td> 638 * <td>Path separator (":" on UNIX)</td></tr> 639 * <tr><td><code>line.separator</code></td> 640 * <td>Line separator ("\n" on UNIX)</td></tr> 641 * <tr><td><code>user.name</code></td> 642 * <td>User's account name</td></tr> 643 * <tr><td><code>user.home</code></td> 644 * <td>User's home directory</td></tr> 645 * <tr><td><code>user.dir</code></td> 646 * <td>User's current working directory</td></tr> 647 * </tbody> 648 * </table> 649 * <p> 650 * Multiple paths in a system property value are separated by the path 651 * separator character of the platform. 652 * <p> 653 * Note that even if the security manager does not permit the 654 * <code>getProperties</code> operation, it may choose to permit the 655 * {@link #getProperty(String)} operation. 656 * 657 * @implNote In addition to the standard system properties, the system 658 * properties may include the following keys: 659 * <table class="striped"> 660 * <caption style="display:none">Shows property keys and associated values</caption> 661 * <thead> 662 * <tr><th>Key</th> 663 * <th>Description of Associated Value</th></tr> 664 * </thead> 665 * <tbody> 666 * <tr><td>{@code jdk.module.path}</td> 667 * <td>The application module path</td></tr> 668 * <tr><td>{@code jdk.module.upgrade.path}</td> 669 * <td>The upgrade module path</td></tr> 670 * <tr><td>{@code jdk.module.main}</td> 671 * <td>The module name of the initial/main module</td></tr> 672 * <tr><td>{@code jdk.module.main.class}</td> 673 * <td>The main class name of the initial module</td></tr> 674 * </tbody> 675 * </table> 676 * 677 * @return the system properties 678 * @exception SecurityException if a security manager exists and its 679 * <code>checkPropertiesAccess</code> method doesn't allow access 680 * to the system properties. 681 * @see #setProperties 682 * @see java.lang.SecurityException 683 * @see java.lang.SecurityManager#checkPropertiesAccess() 684 * @see java.util.Properties 685 */ 686 public static Properties getProperties() { 687 SecurityManager sm = getSecurityManager(); 688 if (sm != null) { 689 sm.checkPropertiesAccess(); 690 } 691 692 return props; | 565 566 private static Properties props; 567 private static native Properties initProperties(Properties props); 568 569 /** 570 * Determines the current system properties. 571 * <p> 572 * First, if there is a security manager, its 573 * <code>checkPropertiesAccess</code> method is called with no 574 * arguments. This may result in a security exception. 575 * <p> 576 * The current set of system properties for use by the 577 * {@link #getProperty(String)} method is returned as a 578 * <code>Properties</code> object. If there is no current set of 579 * system properties, a set of system properties is first created and 580 * initialized. This set of system properties always includes values 581 * for the following keys: 582 * <table class="striped"> 583 * <caption style="display:none">Shows property keys and associated values</caption> 584 * <thead> 585 * <tr><th scope="col">Key</th> 586 * <th scope="col">Description of Associated Value</th></tr> 587 * </thead> 588 * <tbody> 589 * <tr><th scope="row"><code>java.version</code></th> 590 * <td>Java Runtime Environment version which may be interpreted 591 * as a {@link Runtime.Version}</td></tr> 592 * <tr><th scope="row"><code>java.vendor</code></th> 593 * <td>Java Runtime Environment vendor</td></tr> 594 * <tr><th scope="row"><code>java.vendor.url</code></th> 595 * <td>Java vendor URL</td></tr> 596 * <tr><th scope="row"><code>java.home</code></th> 597 * <td>Java installation directory</td></tr> 598 * <tr><th scope="row"><code>java.vm.specification.version</code></th> 599 * <td>Java Virtual Machine specification version which may be 600 * interpreted as a {@link Runtime.Version}</td></tr> 601 * <tr><th scope="row"><code>java.vm.specification.vendor</code></th> 602 * <td>Java Virtual Machine specification vendor</td></tr> 603 * <tr><th scope="row"><code>java.vm.specification.name</code></th> 604 * <td>Java Virtual Machine specification name</td></tr> 605 * <tr><th scope="row"><code>java.vm.version</code></th> 606 * <td>Java Virtual Machine implementation version which may be 607 * interpreted as a {@link Runtime.Version}</td></tr> 608 * <tr><th scope="row"><code>java.vm.vendor</code></th> 609 * <td>Java Virtual Machine implementation vendor</td></tr> 610 * <tr><th scope="row"><code>java.vm.name</code></th> 611 * <td>Java Virtual Machine implementation name</td></tr> 612 * <tr><th scope="row"><code>java.specification.version</code></th> 613 * <td>Java Runtime Environment specification version which may be 614 * interpreted as a {@link Runtime.Version}</td></tr> 615 * <tr><th scope="row"><code>java.specification.vendor</code></th> 616 * <td>Java Runtime Environment specification vendor</td></tr> 617 * <tr><th scope="row"><code>java.specification.name</code></th> 618 * <td>Java Runtime Environment specification name</td></tr> 619 * <tr><th scope="row"><code>java.class.version</code></th> 620 * <td>Java class format version number</td></tr> 621 * <tr><th scope="row"><code>java.class.path</code></th> 622 * <td>Java class path</td></tr> 623 * <tr><th scope="row"><code>java.library.path</code></th> 624 * <td>List of paths to search when loading libraries</td></tr> 625 * <tr><th scope="row"><code>java.io.tmpdir</code></th> 626 * <td>Default temp file path</td></tr> 627 * <tr><th scope="row"><code>java.compiler</code></th> 628 * <td>Name of JIT compiler to use</td></tr> 629 * <tr><th scope="row"><code>os.name</code></th> 630 * <td>Operating system name</td></tr> 631 * <tr><th scope="row"><code>os.arch</code></th> 632 * <td>Operating system architecture</td></tr> 633 * <tr><th scope="row"><code>os.version</code></th> 634 * <td>Operating system version</td></tr> 635 * <tr><th scope="row"><code>file.separator</code></th> 636 * <td>File separator ("/" on UNIX)</td></tr> 637 * <tr><th scope="row"><code>path.separator</code></th> 638 * <td>Path separator (":" on UNIX)</td></tr> 639 * <tr><th scope="row"><code>line.separator</code></th> 640 * <td>Line separator ("\n" on UNIX)</td></tr> 641 * <tr><th scope="row"><code>user.name</code></th> 642 * <td>User's account name</td></tr> 643 * <tr><th scope="row"><code>user.home</code></th> 644 * <td>User's home directory</td></tr> 645 * <tr><th scope="row"><code>user.dir</code></th> 646 * <td>User's current working directory</td></tr> 647 * </tbody> 648 * </table> 649 * <p> 650 * Multiple paths in a system property value are separated by the path 651 * separator character of the platform. 652 * <p> 653 * Note that even if the security manager does not permit the 654 * <code>getProperties</code> operation, it may choose to permit the 655 * {@link #getProperty(String)} operation. 656 * 657 * @implNote In addition to the standard system properties, the system 658 * properties may include the following keys: 659 * <table class="striped"> 660 * <caption style="display:none">Shows property keys and associated values</caption> 661 * <thead> 662 * <tr><th scope="col">Key</th> 663 * <th scope="col">Description of Associated Value</th></tr> 664 * </thead> 665 * <tbody> 666 * <tr><th scope="row">{@code jdk.module.path}</th> 667 * <td>The application module path</td></tr> 668 * <tr><th scope="row">{@code jdk.module.upgrade.path}</th> 669 * <td>The upgrade module path</td></tr> 670 * <tr><th scope="row">{@code jdk.module.main}</th> 671 * <td>The module name of the initial/main module</td></tr> 672 * <tr><th scope="row">{@code jdk.module.main.class}</th> 673 * <td>The main class name of the initial module</td></tr> 674 * </tbody> 675 * </table> 676 * 677 * @return the system properties 678 * @exception SecurityException if a security manager exists and its 679 * <code>checkPropertiesAccess</code> method doesn't allow access 680 * to the system properties. 681 * @see #setProperties 682 * @see java.lang.SecurityException 683 * @see java.lang.SecurityManager#checkPropertiesAccess() 684 * @see java.util.Properties 685 */ 686 public static Properties getProperties() { 687 SecurityManager sm = getSecurityManager(); 688 if (sm != null) { 689 sm.checkPropertiesAccess(); 690 } 691 692 return props; |