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 String
DAEMON_USER
static String
GENTOO_USER
-
Constructor Summary
Constructors Constructor Description SystemVersion()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getAndroidVersion()
Identical to android.os.Build.VERSION.SDK_INT.static int
getCores()
Runtime.getRuntime().availableProcssors()static long
getMaxMemory()
Runtime.getRuntime().maxMemory() but check for bogus valuesstatic 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 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 Androidstatic boolean
isARM()
static boolean
isGentoo()
static boolean
isGNU()
gij or JamVM with GNU Classpathstatic boolean
isJava(int minVersion)
Handles Android alsostatic boolean
isJava(String minVersion)
Handles Android, and minVersions in both forms (e.g.static boolean
isJava10()
static boolean
isJava11()
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)
-
-
-
Field Detail
-
DAEMON_USER
public static final String DAEMON_USER
- See Also:
- Constant Field Values
-
GENTOO_USER
public static final String GENTOO_USER
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
-
-