Package 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
Since:
0.9.3 consolidated from various places
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Identical to android.os.Build.VERSION.SDK_INT.
    static String
    returns the architecture of the system running I2P as a string for reference in clients.config and plugin.config files.
    static int
    Runtime.getRuntime().availableProcssors()
    static long
    Runtime.getRuntime().maxMemory() but check for bogus values
    static String
    returns the OS of the system running I2P as a lower-case string for reference in clients.config and plugin.config files.
    static TimeZone
    The system's time zone, which is probably different from the JVM time zone, because Router changes the JVM default to GMT.
    static TimeZone
    The system's time zone, which is probably different from the JVM time zone, because Router changes the JVM default to GMT.
    static boolean
    Is the wrapper present? Same as I2PAppContext.hasWrapper()
    static boolean
    This isn't always correct.
    static boolean
     
    static boolean
    Apache Harmony JVM, or Android
    static boolean
     
    static boolean
     
    static boolean
    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
     
    static boolean
     
    static boolean
    Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0 as it handles Android also, where java.version = "0".
    static boolean
    Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.7") >= 0 as it handles Android also, where java.version = "0".
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
    Our best guess on whether this is a slow architecture / OS / JVM, using some simple heuristics.
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
    Is this a very slow interpreted mode VM?
    static void
    main(String[] args)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SystemVersion

      public SystemVersion()
  • Method Details

    • 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
      Since:
      0.9.53
    • 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
      Since:
      0.9.53
    • isWindows

      public static boolean isWindows()
    • isMac

      public static boolean isMac()
    • isAndroid

      public static boolean isAndroid()
    • isApache

      public static boolean isApache()
      Apache Harmony JVM, or Android
    • isGNU

      public static boolean isGNU()
      gij or JamVM with GNU Classpath
    • isGentoo

      public static boolean isGentoo()
      Since:
      0.9.23
    • isOpenJDK

      public static boolean isOpenJDK()
      Since:
      0.9.26
    • isARM

      public static boolean isARM()
      Since:
      0.9.8
    • isX86

      public static boolean isX86()
      Since:
      0.9.14
    • isZeroVM

      public static boolean isZeroVM()
      Is this a very slow interpreted mode VM?
      Since:
      0.9.38
    • isSlow

      public static boolean isSlow()
      Our best guess on whether this is a slow architecture / OS / JVM, using some simple heuristics.
      Since:
      0.9.30
    • 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
      Since:
      0.9.14
    • isJava8

      public static boolean isJava8()
      Returns:
      true if Java 1.8 or higher, false for Android.
      Since:
      0.9.15
    • isJava9

      public static boolean isJava9()
      Returns:
      true if Java 9 or higher, false for Android.
      Since:
      0.9.23
    • isJava10

      public static boolean isJava10()
      Returns:
      true if Java 10 or higher, false for Android.
      Since:
      0.9.33
    • isJava11

      public static boolean isJava11()
      Returns:
      true if Java 11 or higher, false for Android.
      Since:
      0.9.35
    • isJava

      public static boolean isJava(int minVersion)
      Handles Android also
      Parameters:
      minVersion - e.g. 11
      Returns:
      true if greater than or equal to minVersion
      Since:
      0.9.41
    • 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
      Since:
      0.9.41
    • 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
    • isLinuxService

      public static boolean isLinuxService()
    • isWindowsService

      public static boolean isWindowsService()
    • isService

      public static boolean isService()
    • 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
    • hasWrapper

      public static boolean hasWrapper()
      Is the wrapper present? Same as I2PAppContext.hasWrapper()
    • getMaxMemory

      public static long getMaxMemory()
      Runtime.getRuntime().maxMemory() but check for bogus values
      Since:
      0.9.8
    • getCores

      public static int getCores()
      Runtime.getRuntime().availableProcssors()
      Returns:
      never smaller than 1
      Since:
      0.9.34
    • 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
      Since:
      0.9.24
    • 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
      Since:
      0.9.24
    • main

      public static void main(String[] args)
      Since:
      0.9.24