< prev index next >

src/java.base/share/classes/java/lang/System.java

Print this page




 601      * <dt>line.separator       <dd>Line separator ("\n" on Unix)
 602      * <dt>user.name            <dd>User account name
 603      * <dt>user.home            <dd>User home directory
 604      * <dt>user.dir             <dd>User's current working directory
 605      * </dl>
 606      */
 607 
 608     private static Properties props;
 609 
 610     /**
 611      * Determines the current system properties.
 612      *
 613      * First, if there is a security manager, its
 614      * {@code checkPropertiesAccess} method is called with no
 615      * arguments. This may result in a security exception.
 616      * <p>
 617      * The current set of system properties for use by the
 618      * {@link #getProperty(String)} method is returned as a
 619      * {@code Properties} object. If there is no current set of
 620      * system properties, a set of system properties is first created and
 621      * initialized. This set of system properties includes a value
 622      * for each of the following keys unless the description of the associated
 623      * value indicates that the value is optional.
 624      * <table class="striped" style="text-align:left">
 625      * <caption style="display:none">Shows property keys and associated values</caption>
 626      * <thead>
 627      * <tr><th scope="col">Key</th>
 628      *     <th scope="col">Description of Associated Value</th></tr>
 629      * </thead>
 630      * <tbody>
 631      * <tr><th scope="row">{@systemProperty java.version}</th>
 632      *     <td>Java Runtime Environment version, which may be interpreted
 633      *     as a {@link Runtime.Version}</td></tr>
 634      * <tr><th scope="row">{@systemProperty java.version.date}</th>
 635      *     <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD
 636      *     format, which may be interpreted as a {@link
 637      *     java.time.LocalDate}</td></tr>
 638      * <tr><th scope="row">{@systemProperty java.vendor}</th>
 639      *     <td>Java Runtime Environment vendor</td></tr>
 640      * <tr><th scope="row">{@systemProperty java.vendor.url}</th>
 641      *     <td>Java vendor URL</td></tr>
 642      * <tr><th scope="row">{@systemProperty java.vendor.version}</th>
 643      *     <td>Java vendor version <em>(optional)</em> </td></tr>
 644      * <tr><th scope="row">{@systemProperty java.home}</th>
 645      *     <td>Java installation directory</td></tr>
 646      * <tr><th scope="row">{@systemProperty java.vm.specification.version}</th>
 647      *     <td>Java Virtual Machine specification version, whose value is the
 648      *     {@linkplain Runtime.Version#feature feature} element of the
 649      *     {@linkplain Runtime#version() runtime version}</td></tr>
 650      * <tr><th scope="row">{@systemProperty java.vm.specification.vendor}</th>
 651      *     <td>Java Virtual Machine specification vendor</td></tr>
 652      * <tr><th scope="row">{@systemProperty java.vm.specification.name}</th>
 653      *     <td>Java Virtual Machine specification name</td></tr>
 654      * <tr><th scope="row">{@systemProperty java.vm.version}</th>
 655      *     <td>Java Virtual Machine implementation version which may be
 656      *     interpreted as a {@link Runtime.Version}</td></tr>
 657      * <tr><th scope="row">{@systemProperty java.vm.vendor}</th>
 658      *     <td>Java Virtual Machine implementation vendor</td></tr>
 659      * <tr><th scope="row">{@systemProperty java.vm.name}</th>
 660      *     <td>Java Virtual Machine implementation name</td></tr>
 661      * <tr><th scope="row">{@systemProperty java.specification.version}</th>
 662      *     <td>Java Runtime Environment specification version, whose value is
 663      *     the {@linkplain Runtime.Version#feature feature} element of the


1766      * This method calls the {@code exit} method in class
1767      * {@code Runtime}. This method never returns normally.
1768      * <p>
1769      * The call {@code System.exit(n)} is effectively equivalent to
1770      * the call:
1771      * <blockquote><pre>
1772      * Runtime.getRuntime().exit(n)
1773      * </pre></blockquote>
1774      *
1775      * @param      status   exit status.
1776      * @throws  SecurityException
1777      *        if a security manager exists and its {@code checkExit}
1778      *        method doesn't allow exit with the specified status.
1779      * @see        java.lang.Runtime#exit(int)
1780      */
1781     public static void exit(int status) {
1782         Runtime.getRuntime().exit(status);
1783     }
1784 
1785     /**
1786      * Runs the garbage collector in the Java Virtual Machine.
1787      * <p>
1788      * Calling the {@code gc} method suggests that the Java Virtual Machine
1789      * expend effort toward recycling unused objects in order to
1790      * make the memory they currently occupy available for reuse
1791      * by the Java Virtual Machine.
1792      * When control returns from the method call, the Java Virtual Machine
1793      * has made a best effort to reclaim space from all unused objects.
1794      * There is no guarantee that this effort will recycle any particular
1795      * number of unused objects, reclaim any particular amount of space, or
1796      * complete at any particular time, if at all, before the method returns or ever.
1797      * <p>
1798      * The call {@code System.gc()} is effectively equivalent to the
1799      * call:
1800      * <blockquote><pre>
1801      * Runtime.getRuntime().gc()
1802      * </pre></blockquote>
1803      *
1804      * @see     java.lang.Runtime#gc()
1805      */
1806     public static void gc() {
1807         Runtime.getRuntime().gc();
1808     }
1809 
1810     /**
1811      * Runs the finalization methods of any objects pending finalization.
1812      *
1813      * Calling this method suggests that the Java Virtual Machine expend
1814      * effort toward running the {@code finalize} methods of objects
1815      * that have been found to be discarded but whose {@code finalize}
1816      * methods have not yet been run. When control returns from the




 601      * <dt>line.separator       <dd>Line separator ("\n" on Unix)
 602      * <dt>user.name            <dd>User account name
 603      * <dt>user.home            <dd>User home directory
 604      * <dt>user.dir             <dd>User's current working directory
 605      * </dl>
 606      */
 607 
 608     private static Properties props;
 609 
 610     /**
 611      * Determines the current system properties.
 612      *
 613      * First, if there is a security manager, its
 614      * {@code checkPropertiesAccess} method is called with no
 615      * arguments. This may result in a security exception.
 616      * <p>
 617      * The current set of system properties for use by the
 618      * {@link #getProperty(String)} method is returned as a
 619      * {@code Properties} object. If there is no current set of
 620      * system properties, a set of system properties is first created and
 621      * initialized. This set of system properties always includes values
 622      * for the following keys:

 623      * <table class="striped" style="text-align:left">
 624      * <caption style="display:none">Shows property keys and associated values</caption>
 625      * <thead>
 626      * <tr><th scope="col">Key</th>
 627      *     <th scope="col">Description of Associated Value</th></tr>
 628      * </thead>
 629      * <tbody>
 630      * <tr><th scope="row">{@systemProperty java.version}</th>
 631      *     <td>Java Runtime Environment version, which may be interpreted
 632      *     as a {@link Runtime.Version}</td></tr>
 633      * <tr><th scope="row">{@systemProperty java.version.date}</th>
 634      *     <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD
 635      *     format, which may be interpreted as a {@link
 636      *     java.time.LocalDate}</td></tr>
 637      * <tr><th scope="row">{@systemProperty java.vendor}</th>
 638      *     <td>Java Runtime Environment vendor</td></tr>
 639      * <tr><th scope="row">{@systemProperty java.vendor.url}</th>
 640      *     <td>Java vendor URL</td></tr>
 641      * <tr><th scope="row">{@systemProperty java.vendor.version}</th>
 642      *     <td>Java vendor version</td></tr>
 643      * <tr><th scope="row">{@systemProperty java.home}</th>
 644      *     <td>Java installation directory</td></tr>
 645      * <tr><th scope="row">{@systemProperty java.vm.specification.version}</th>
 646      *     <td>Java Virtual Machine specification version, whose value is the
 647      *     {@linkplain Runtime.Version#feature feature} element of the
 648      *     {@linkplain Runtime#version() runtime version}</td></tr>
 649      * <tr><th scope="row">{@systemProperty java.vm.specification.vendor}</th>
 650      *     <td>Java Virtual Machine specification vendor</td></tr>
 651      * <tr><th scope="row">{@systemProperty java.vm.specification.name}</th>
 652      *     <td>Java Virtual Machine specification name</td></tr>
 653      * <tr><th scope="row">{@systemProperty java.vm.version}</th>
 654      *     <td>Java Virtual Machine implementation version which may be
 655      *     interpreted as a {@link Runtime.Version}</td></tr>
 656      * <tr><th scope="row">{@systemProperty java.vm.vendor}</th>
 657      *     <td>Java Virtual Machine implementation vendor</td></tr>
 658      * <tr><th scope="row">{@systemProperty java.vm.name}</th>
 659      *     <td>Java Virtual Machine implementation name</td></tr>
 660      * <tr><th scope="row">{@systemProperty java.specification.version}</th>
 661      *     <td>Java Runtime Environment specification version, whose value is
 662      *     the {@linkplain Runtime.Version#feature feature} element of the


1765      * This method calls the {@code exit} method in class
1766      * {@code Runtime}. This method never returns normally.
1767      * <p>
1768      * The call {@code System.exit(n)} is effectively equivalent to
1769      * the call:
1770      * <blockquote><pre>
1771      * Runtime.getRuntime().exit(n)
1772      * </pre></blockquote>
1773      *
1774      * @param      status   exit status.
1775      * @throws  SecurityException
1776      *        if a security manager exists and its {@code checkExit}
1777      *        method doesn't allow exit with the specified status.
1778      * @see        java.lang.Runtime#exit(int)
1779      */
1780     public static void exit(int status) {
1781         Runtime.getRuntime().exit(status);
1782     }
1783 
1784     /**
1785      * Runs the garbage collector.
1786      *
1787      * Calling the {@code gc} method suggests that the Java Virtual
1788      * Machine expend effort toward recycling unused objects in order to
1789      * make the memory they currently occupy available for quick reuse.
1790      * When control returns from the method call, the Java Virtual
1791      * Machine has made a best effort to reclaim space from all discarded
1792      * objects.



1793      * <p>
1794      * The call {@code System.gc()} is effectively equivalent to the
1795      * call:
1796      * <blockquote><pre>
1797      * Runtime.getRuntime().gc()
1798      * </pre></blockquote>
1799      *
1800      * @see     java.lang.Runtime#gc()
1801      */
1802     public static void gc() {
1803         Runtime.getRuntime().gc();
1804     }
1805 
1806     /**
1807      * Runs the finalization methods of any objects pending finalization.
1808      *
1809      * Calling this method suggests that the Java Virtual Machine expend
1810      * effort toward running the {@code finalize} methods of objects
1811      * that have been found to be discarded but whose {@code finalize}
1812      * methods have not yet been run. When control returns from the


< prev index next >