public class SystemUtilities extends Object
| Modifier and Type | Method and Description |
|---|---|
static long |
currentTimeMillis()
Like
System.currentTimeMillis() except on Windows platforms, this returns time with precision to the nearest millisecond instead of nearest 15 milliseconds
which is the accuracy of System.currentTimeMillis(). |
static long |
getAvailableMemory()
Get the amount of available (free) memory in bytes.
|
static long |
getAvailableMemoryAfterMostRecentGarbageCollection()
Similar to
getAvailableMemory() but returns the amount of available (free) memory in bytes after the Java virtual machine last performed a garbage collection. |
static long |
getCurrentThreadCpuTime() |
static Locale |
getDefaultLocale()
Returns the real System default locale.
|
static long |
getJavaVirtualMachineCpuTime() |
static long |
getUsedMemory()
Get the amount of used memory in bytes.
|
static boolean |
is64BitOS()
Return true if we are running under any 64-bit operating system.
|
static boolean |
is64BitVM()
Returns true if this Java VM is probably 64 bit (rather than 32 bit).
|
static boolean |
isAvailableMemoryLessThan(long memoryInMB)
Checks whether the available memory has dropped below the specified amount.
|
static boolean |
isAvailableMemoryTooLow()
Checks whether the available memory has dropped below a level such that we shouldn't continue with non-essential operations.
|
static boolean |
isJava6OrLater()
Deprecated.
As of version 6.0.0 Geneious is Java 6 or later only, this will always return true
|
static boolean |
isJava7OrLater()
Returns true if this VM is Java 7 or later.
|
static boolean |
isLinux()
Return true if we are running under any Linux operating system.
|
static boolean |
isMac()
Return true if we are running under any Mac operating system.
|
static boolean |
isRetinaDisplay() |
static boolean |
isSolaris()
Deprecated.
Geneious is no longer supported on Solaris
|
static boolean |
isSolarisSparc()
Deprecated.
Geneious is no longer supported on Solaris
|
static boolean |
isSolarisX86()
Deprecated.
Geneious is no longer supported on Solaris
|
static boolean |
isWindows()
Return true if we are running under any Windows operating system.
|
static long |
milliTime()
Returns a counter that can be used for measuring elapsed time in milliseconds.
|
static void |
openUrl(URL url)
Open the system's default browser and navigate to the specified url.
|
static void |
openUrl(URL url,
Component owner)
Open the system's default browser and navigate to the specified url.
|
public static boolean isMac()
public static boolean isWindows()
public static boolean isLinux()
@Deprecated public static boolean isSolaris()
isSolarisSparc(),
isSolarisX86()@Deprecated public static boolean isSolarisSparc()
isSolaris(),
isSolarisX86()@Deprecated public static boolean isSolarisX86()
isSolaris(),
isSolarisSparc()public static boolean is64BitOS()
is64BitVM()public static void openUrl(URL url)
url - URL to open in a browserpublic static void openUrl(URL url, Component owner)
url - URL to open in a browserowner - Any component within the Window which will be the owner of any message dialogs. If null, the currently
focused document frame (or JDialog with getClientProperty(ALLOW_AS_PARENT) != null) is used as the owner.public static long getAvailableMemory()
System.gc() first may increase the returned value.public static long getUsedMemory()
System.gc() first may decrease the returned value.public static long getAvailableMemoryAfterMostRecentGarbageCollection()
getAvailableMemory() but returns the amount of available (free) memory in bytes after the Java virtual machine last performed a garbage collection. Note that this method itself does not perform or cause a garbage collection to occur
A situation where you might use this rather than isAvailableMemoryLessThan(long) is if there is if the code can perform an alternative strategy to using lots of memory and the code doesn't want
to incur the cost of performing a system gc, which can potentially take several minutes if there is insufficient memory.public static boolean isAvailableMemoryLessThan(long memoryInMB)
SoftReferences to be garbage collected if there
is currently less than memoryInMB available and by freeing those SoftReferences we could go back above memoryInMB free memory.
Note, if a lot of memory is currently in use and there is less memory available than this method requests, this method can
be very slow (several minutes). Instead, usage of getAvailableMemoryAfterMostRecentGarbageCollection() is suggested where possible.memoryInMB - Minimum required multiple of a Mebibyte (1,048,576 bytes) required. We recommend using a value of at least 100, or things can get very slow on systems with many GB of memory close to their limitpublic static boolean isAvailableMemoryTooLow()
public static long currentTimeMillis()
System.currentTimeMillis() except on Windows platforms, this returns time with precision to the nearest millisecond instead of nearest 15 milliseconds
which is the accuracy of System.currentTimeMillis().
Note that the returned precision is not actually closer to the real time, but is instead always offset by a fixed difference (for any given
instance of the Java VM) between the real time and the returned time. This offset is constant for the lifetime of a Java VM and is always <= the accuracy of System.currentTimeMillis (15 milliseconds on Windows).
For example for the lifetime of 1 instance of the Java VM, this method may return the true time always offset by 10 milliseconds. On a later instance
of the Java VM, this method may return the true time always offset by 3 milliseconds.
System.currentTimeMillis() should be used for measuring elapsed time. The values returned from these methods can go backwards due to time synchronization software. Use milliTime() or System.nanoTime() instead.public static long milliTime()
System.nanoTime() / 1,000,000.System.nanoTime() / 1,000,000public static long getCurrentThreadCpuTime()
public static long getJavaVirtualMachineCpuTime()
public static Locale getDefaultLocale()
Locale.getDefault() to Locale.UK as a sort of messy hack for importing/exporting file formats using dates.Locale.getDefault() to Locale.UK.public static boolean isJava6OrLater()
public static boolean isJava7OrLater()
public static boolean is64BitVM()
is64BitOS()public static boolean isRetinaDisplay()