net.i2p.util

## Class SystemVersion

- java.lang.Object
- - net.i2p.util.SystemVersion

-     public abstract class SystemVersion
      extends Object

  Methods to find out what system we are running on

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DAEMON_USER`
    `static boolean` | `DEFAULT_OVERRIDE_IS_SLOW`
    `static String` | `GENTOO_USER`
    `static String` | `PROP_OVERRIDE_IS_SLOW`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SystemVersion()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getActiveThreads()` Returns the current number of active (live) threads in the JVM.
    `static int` | `getAndroidVersion()` Identical to android.os.Build.VERSION.SDK_INT.
    `static String` | `getArch()` returns the architecture of the system running I2P as a string for reference in clients.config and plugin.config files.
    `static int` | `getCores()` Runtime.getRuntime().availableProcssors()
    `static int` | `getCPULoad()` Retrieve CPU Load of the JVM.
    `static int` | `getCPULoadAvg()` Retrieve CPU Load Average of the JVM.
    `static long` | `getMaxMemory()` Runtime.getRuntime().maxMemory() but check for bogus values
    `static String` | `getOS()` returns the OS of the system running I2P as a lower-case string for reference in clients.config and plugin.config files.
    `static int` | `getSystemLoad()` Retrieve System Load as percentage (100% equals full system load)
    `static TimeZone` | `getSystemTimeZone()` The system's time zone, which is probably different from the JVM time zone, because Router changes the JVM default to GMT.
    `static TimeZone` | `getSystemTimeZone(I2PAppContext ctx)` The system's time zone, which is probably different from the JVM time zone, because Router changes the JVM default to GMT.
    `static int` | `getTunnelBuildSuccess()` Retrieve Tunnel build success as a percentage.
    `static boolean` | `hasWrapper()` Is the wrapper present? Same as I2PAppContext.hasWrapper()
    `static boolean` | `is64Bit()` This isn't always correct.
    `static boolean` | `isAndroid()`
    `static boolean` | `isApache()` Apache Harmony JVM, or Android
    `static boolean` | `isARM()`
    `static boolean` | `isGentoo()`
    `static boolean` | `isGNU()` gij or JamVM with GNU Classpath
    `static boolean` | `isJava(int minVersion)` Handles Android also
    `static boolean` | `isJava(String minVersion)` Handles Android, and minVersions in both forms (e.g.
    `static boolean` | `isJava10()`
    `static boolean` | `isJava11()`
    `static boolean` | `isJava12()`
    `static boolean` | `isJava13()`
    `static boolean` | `isJava14()`
    `static boolean` | `isJava15()`
    `static boolean` | `isJava16()`
    `static boolean` | `isJava17()`
    `static boolean` | `isJava18()`
    `static boolean` | `isJava19()`
    `static boolean` | `isJava20()`
    `static boolean` | `isJava21()`
    `static boolean` | `isJava22()`
    `static boolean` | `isJava6()` Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0 as it handles Android also, where java.version = "0".
    `static boolean` | `isJava7()` Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.7") >= 0 as it handles Android also, where java.version = "0".
    `static boolean` | `isJava8()`
    `static boolean` | `isJava9()`
    `static boolean` | `isLinuxService()`
    `static boolean` | `isMac()`
    `static boolean` | `isOpenJDK()`
    `static boolean` | `isService()`
    `static boolean` | `isSlow()` Our best guess on whether this is a slow architecture / OS / JVM, using some simple heuristics.
    `static boolean` | `isWindows()`
    `static boolean` | `isWindowsService()`
    `static boolean` | `isX86()`
    `static boolean` | `isZeroVM()` Is this a very slow interpreted mode VM?
    `static void` | `main(String[] args)`
    `static int` | `usableCores()` calculate how many (virtual) cores should be actually used by a thread pool

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DAEMON_USER

          public static final String DAEMON_USER

      See Also:
        Constant Field Values

    - #### DEFAULT_OVERRIDE_IS_SLOW

          public static final boolean DEFAULT_OVERRIDE_IS_SLOW

      See Also:
        Constant Field Values

    - #### GENTOO_USER

          public static final String GENTOO_USER

      See Also:
        Constant Field Values

    - #### PROP_OVERRIDE_IS_SLOW

          public static final String PROP_OVERRIDE_IS_SLOW

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SystemVersion

          public SystemVersion()

  - ### Method Detail

    - #### getActiveThreads

          public static int getActiveThreads()

      Returns the current number of active (live) threads in the JVM. This includes both daemon and non-daemon threads.
      Returns:
        the estimated number of active threads, or 0 if context or stat manager is unavailable

    - #### getAndroidVersion

          public static int getAndroidVersion()

      Identical to android.os.Build.VERSION.SDK_INT. For use outside of Android code.
      Returns:
        The SDK (API) version, e.g. 8 for Froyo, 0 if unknown

    - #### getArch

          public static String getArch()

      returns the architecture of the system running I2P as a string for reference in clients.config and plugin.config files. matches the conventions of the Go cross compiler
      Returns:
        the architecture of the system running I2P as a string

    - #### getCores

          public static int getCores()

      Runtime.getRuntime().availableProcssors()
      Returns:
        never smaller than 1

    - #### getCPULoad

          public static int getCPULoad()

      Retrieve CPU Load of the JVM.

    - #### getCPULoadAvg

          public static int getCPULoadAvg()

      Retrieve CPU Load Average of the JVM.

    - #### getMaxMemory

          public static long getMaxMemory()

      Runtime.getRuntime().maxMemory() but check for bogus values

    - #### getOS

          public static String getOS()

      returns the OS of the system running I2P as a lower-case string for reference in clients.config and plugin.config files. matches the conventions of the Go cross compiler
      Returns:
        the OS of the system running I2P as a lower-case string

    - #### getSystemLoad

          public static int getSystemLoad()

      Retrieve System Load as percentage (100% equals full system load)

    - #### getSystemTimeZone

          public static TimeZone getSystemTimeZone()

      The system's time zone, which is probably different from the JVM time zone, because Router changes the JVM default to GMT. It saves the old default in the context properties where we can get it. Use this to format a time in local time zone with DateFormat.setTimeZone().
      Returns:
        non-null

    - #### getSystemTimeZone

          public static TimeZone getSystemTimeZone(I2PAppContext ctx)

      The system's time zone, which is probably different from the JVM time zone, because Router changes the JVM default to GMT. It saves the old default in the context properties where we can get it. Use this to format a time in local time zone with DateFormat.setTimeZone().
      Returns:
        non-null

    - #### getTunnelBuildSuccess

          public static int getTunnelBuildSuccess()

      Retrieve Tunnel build success as a percentage.

    - #### hasWrapper

          public static boolean hasWrapper()

      Is the wrapper present? Same as I2PAppContext.hasWrapper()

    - #### is64Bit

          public static boolean is64Bit()

      This isn't always correct. http://stackoverflow.com/questions/807263/how-do-i-detect-which-kind-of-jre-is-installed-32bit-vs-64bit http://mark.koli.ch/2009/10/javas-osarch-system-property-is-the-bitness-of-the-jre-not-the-operating-system.html http://mark.koli.ch/2009/10/reliably-checking-os-bitness-32-or-64-bit-on-windows-with-a-tiny-c-app.html sun.arch.data.model not on all JVMs sun.arch.data.model == 64 => 64 bit processor sun.arch.data.model == 32 => A 32 bit JVM but could be either 32 or 64 bit processor or libs os.arch contains "64" could be 32 or 64 bit libs

    - #### isAndroid

          public static boolean isAndroid()

    - #### isApache

          public static boolean isApache()

      Apache Harmony JVM, or Android

    - #### isARM

          public static boolean isARM()

    - #### isGentoo

          public static boolean isGentoo()

    - #### isGNU

          public static boolean isGNU()

      gij or JamVM with GNU Classpath

    - #### isJava

          public static boolean isJava(int minVersion)

      Handles Android also
      Parameters:
        `minVersion` - e.g. 11
      Returns:
        true if greater than or equal to minVersion

    - #### isJava

          public static boolean isJava(String minVersion)

      Handles Android, and minVersions in both forms (e.g. 11 or 1.11)
      Parameters:
        `minVersion` - either 1.x or x form works
      Returns:
        true if greater than or equal to minVersion

    - #### isJava10

          public static boolean isJava10()

      Returns:
        true if Java 10 or higher, false for Android.

    - #### isJava11

          public static boolean isJava11()

      Returns:
        true if Java 11 or higher, false for Android.

    - #### isJava12

          public static boolean isJava12()

      Returns:
        true if Java 12 or higher, false for Android.

    - #### isJava13

          public static boolean isJava13()

      Returns:
        true if Java 13 or higher, false for Android.

    - #### isJava14

          public static boolean isJava14()

      Returns:
        true if Java 14 or higher, false for Android.

    - #### isJava15

          public static boolean isJava15()

      Returns:
        true if Java 15 or higher, false for Android.

    - #### isJava16

          public static boolean isJava16()

      Returns:
        true if Java 16 or higher, false for Android.

    - #### isJava17

          public static boolean isJava17()

      Returns:
        true if Java 17 or higher, false for Android.

    - #### isJava18

          public static boolean isJava18()

      Returns:
        true if Java 18 or higher, false for Android.

    - #### isJava19

          public static boolean isJava19()

      Returns:
        true if Java 19 or higher, false for Android.

    - #### isJava20

          public static boolean isJava20()

      Returns:
        true if Java 20 or higher, false for Android.

    - #### isJava21

          public static boolean isJava21()

      Returns:
        true if Java 21 or higher, false for Android.

    - #### isJava22

          public static boolean isJava22()

      Returns:
        true if Java 21 or higher, false for Android.

    - #### isJava6

          public static boolean isJava6()

      Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0 as it handles Android also, where java.version = "0".
      Returns:
        true if Java 1.6 or higher, or Android API 9 or higher

    - #### isJava7

          public static boolean isJava7()

      Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.7") >= 0 as it handles Android also, where java.version = "0".
      Returns:
        true if Java 1.7 or higher, or Android API 19 or higher

    - #### isJava8

          public static boolean isJava8()

      Returns:
        true if Java 1.8 or higher, false for Android.

    - #### isJava9

          public static boolean isJava9()

      Returns:
        true if Java 9 or higher, false for Android.

    - #### isLinuxService

          public static boolean isLinuxService()

    - #### isMac

          public static boolean isMac()

    - #### isOpenJDK

          public static boolean isOpenJDK()

    - #### isService

          public static boolean isService()

    - #### isSlow

          public static boolean isSlow()

      Our best guess on whether this is a slow architecture / OS / JVM, using some simple heuristics.

    - #### isWindows

          public static boolean isWindows()

    - #### isWindowsService

          public static boolean isWindowsService()

    - #### isX86

          public static boolean isX86()

    - #### isZeroVM

          public static boolean isZeroVM()

      Is this a very slow interpreted mode VM?

    - #### main

          public static void main(String[] args)

    - #### usableCores

          public static int usableCores()

      calculate how many (virtual) cores should be actually used by a thread pool