public class SystemUtil extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SYSTEM_MAC_OS |
static java.lang.String |
SYSTEM_UNIX |
static java.lang.String |
SYSTEM_WINDOWS |
Constructor and Description |
---|
SystemUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
addToJavaLibraryPath(java.lang.String[] directories) |
static java.awt.image.BufferedImage |
createCompatibleImage(int width,
int height) |
static java.awt.image.BufferedImage |
createCompatibleImage(int width,
int height,
int transparency) |
static java.awt.image.VolatileImage |
createCompatibleVolatileImage(int width,
int height) |
static java.awt.image.VolatileImage |
createCompatibleVolatileImage(int width,
int height,
int transparency) |
static java.lang.Process |
exec(java.lang.String cmd)
Execute a system command and return the attached process.
|
static java.lang.Process |
exec(java.lang.String cmd,
java.lang.String dir)
Execute a system command and return the attached process.
|
static java.lang.Process |
execJAR(java.lang.String jarPath)
Launch specified jar file.
|
static java.lang.Process |
execJAR(java.lang.String jarPath,
java.lang.String appArgs)
Launch specified jar file.
|
static java.lang.Process |
execJAR(java.lang.String jarPath,
java.lang.String vmArgs,
java.lang.String appArgs)
Launch specified jar file.
|
static java.lang.Process |
execJAR(java.lang.String jarPath,
java.lang.String vmArgs,
java.lang.String appArgs,
java.lang.String workDir)
Launch specified jar file.
|
static int |
getAvailableProcessors()
Deprecated.
Use
getNumberOfCPUs() instead |
static java.lang.ClassLoader |
getContextClassLoader() |
static int |
getCpuLoad()
Return average CPU load of the application processes from the last call
(-1 if no available) |
static int |
getCtrlMask()
Deprecated.
Use
getMenuCtrlMask() instead. |
static java.awt.GraphicsConfiguration |
getDefaultGraphicsConfiguration()
Return the default graphics configuration.
|
static java.awt.GraphicsDevice |
getDefaultScreenDevice()
Return the default screen device.
|
static java.awt.Desktop |
getDesktop() |
static java.awt.Rectangle |
getDesktopBounds()
Return the entire desktop bounds (take multi screens in account)
|
static java.awt.Rectangle |
getDesktopBounds(boolean removeInsets)
Return the entire desktop bounds (take multi screens in account).
|
static long |
getFreeMemory()
Return free physic memory of system (in bytes)
|
static long |
getJavaAllocatedMemory()
Return memory currently allocated by the JVM (in bytes)
|
static int |
getJavaArchDataModel()
Returns the JVM data architecture model.
|
static long |
getJavaFreeMemory()
Return total amount of free memory available to the JVM (in bytes)
|
static long |
getJavaMaxMemory()
Return maximum amount of memory the JVM will attempt to use (in bytes)
|
static java.lang.String |
getJavaName()
Returns the JVM name.
|
static long |
getJavaTotalMemory()
Deprecated.
Use
getJavaAllocatedMemory() instead. |
static long |
getJavaUsedMemory()
Return actual memory used by the JVM (in bytes)
|
static java.lang.String |
getJavaVersion()
Returns the JVM version.
|
static double |
getJavaVersionAsNumber()
Returns the JVM version in number format (ex: 6.091, 7.071, 8.151..)
|
static Version |
getJavaVersionAsVersion()
Returns the JVM integer version (ex: 6.0.91, 7.0.71, 8.0.151..)
|
static java.awt.GraphicsEnvironment |
getLocalGraphicsEnvironment() |
static java.awt.Rectangle |
getMaximumWindowBounds()
GraphicsEnvironment.getMaximumWindowBounds() |
static int |
getMenuCtrlMask()
Return the CTRL key mask used for Menu shortcut.
|
static int |
getNumberOfCPUs()
Return total number of processors or cores available to the JVM (same as system)
|
static java.lang.String |
getOSArch()
Returns the Operating System architecture name.
|
static java.lang.String |
getOSArchIdString()
Return an id OS architecture string
example : "win32", "win64", "mac32", "mac64", "unix32"... |
static java.lang.String |
getOSName()
Returns the Operating System name.
|
static java.lang.String |
getOSNameId()
Return an id OS string :
Windows system return SystemUtil.SYSTEM_WINDOWS MAC OS return SystemUtil.SYSTEM_MAC_OS Unix system return SystemUtil.SYSTEM_UNIX An empty string is returned is OS is unknown. |
static java.lang.String |
getOSVersion()
Returns the Operating System version.
|
static long |
getProcessCpuTime()
Return system process CPU time
|
static java.lang.String |
getProperty(java.lang.String name) |
static java.lang.String |
getProperty(java.lang.String name,
java.lang.String defaultValue) |
static java.awt.Rectangle |
getScreenBounds(java.awt.GraphicsDevice graphicsDevice,
boolean removeInsets)
Return bounds for specified screen.
|
static java.awt.GraphicsDevice |
getScreenDevice(int index)
Return the screen device corresponding to specified index.
|
static java.awt.GraphicsDevice |
getScreenDevice(java.awt.Point position)
Returns the screen device corresponding to the given position.
|
static java.awt.GraphicsDevice |
getScreenDevice(java.awt.Rectangle region)
Returns the main screen device corresponding to the given region.
|
static int |
getScreenDeviceCount()
Return the number of screen device.
|
static java.util.List<java.awt.GraphicsDevice> |
getScreenDevices()
Return all available screen devices.
|
static java.util.List<java.awt.GraphicsDevice> |
getScreenDevices(java.awt.Rectangle region)
Returns all screen device intersecting the given region.
|
static java.awt.BufferCapabilities |
getSystemBufferCapabilities() |
static java.lang.ClassLoader |
getSystemClassLoader() |
static java.awt.image.ColorModel |
getSystemColorModel() |
static java.awt.image.ColorModel |
getSystemColorModel(int transparency) |
static int |
getSystemCpuLoad()
Deprecated.
Use
getCpuLoad() instead |
static int |
getSystemCtrlMask()
Deprecated.
Use
getMenuCtrlMask() instead |
static java.awt.DisplayMode |
getSystemDisplayMode()
GraphicsDevice.getDisplayMode() |
static long |
getSystemFreeMemory()
Deprecated.
Use
getFreeMemory() instead |
static java.awt.GraphicsConfiguration |
getSystemGraphicsConfiguration()
Deprecated.
Use
getDefaultGraphicsConfiguration() instead. |
static java.awt.ImageCapabilities |
getSystemImageCapabilities() |
static long |
getSystemProcessCpuTime()
Deprecated.
Use
getProcessCpuTime() instead |
static long |
getSystemTotalMemory()
Deprecated.
Use
getTotalMemory() instead |
static java.lang.String |
getTempDirectory()
Returns default temporary directory.
|
static java.lang.String |
getTempLibraryDirectory()
Returns temporary native library path (used to load native libraries from plugin)
|
static long |
getTotalMemory()
Return total physic memory of system (in bytes)
|
static java.lang.String |
getUserName()
Returns the user name.
|
static boolean |
is32bits()
Returns true is the JVM is 32 bits.
|
static boolean |
is64bits()
Returns true is the JVM is 64 bits.
|
static boolean |
isHeadLess()
Returns true if current system is "head less" (no screen output device).
|
static boolean |
isLinkSupported()
Returns true is the operating system support link (symbolic or not).
|
static boolean |
isMac()
Returns true is the Operating System is Mac OS based.
|
static boolean |
isUnix()
Returns true is the Operating System is Unix / Linux based.
|
static boolean |
isWindow()
Deprecated.
Use
isWindows() instead. |
static boolean |
isWindows()
Returns true is the Operating System is Windows based.
|
static boolean |
isWindows64()
Returns true is the Operating System is Windows 64 bits whatever is the JVM installed (32 or 64 bits).
|
static void |
loadLibrary(java.lang.String pathname)
Load the specified native library.
|
static void |
loadLibrary(java.lang.String dir,
java.lang.String name)
Load the specified native library.
|
static boolean |
openFolder(java.lang.String folder)
Launch the system file manager on specified folder (if supported)
|
static java.lang.String |
setProperty(java.lang.String name,
java.lang.String value) |
public static final java.lang.String SYSTEM_WINDOWS
public static final java.lang.String SYSTEM_MAC_OS
public static final java.lang.String SYSTEM_UNIX
public SystemUtil()
public static java.lang.Process execJAR(java.lang.String jarPath, java.lang.String vmArgs, java.lang.String appArgs, java.lang.String workDir)
jarPath
- jar file path.vmArgs
- arguments for the java virtual machine.appArgs
- arguments for jar application.workDir
- working directory.public static java.lang.Process execJAR(java.lang.String jarPath, java.lang.String vmArgs, java.lang.String appArgs)
jarPath
- jar file path.vmArgs
- arguments for the java virtual machine.appArgs
- arguments for jar application.public static java.lang.Process execJAR(java.lang.String jarPath, java.lang.String appArgs)
jarPath
- jar file path.appArgs
- arguments for jar application.public static java.lang.Process execJAR(java.lang.String jarPath)
jarPath
- jar file path.public static java.lang.Process exec(java.lang.String cmd)
cmd
- system command to execute.public static java.lang.Process exec(java.lang.String cmd, java.lang.String dir)
cmd
- system command to execute.dir
- the working directory of the subprocess, or null if the subprocess should inherit the
working directory of the current process.public static java.awt.image.BufferedImage createCompatibleImage(int width, int height)
public static java.awt.image.BufferedImage createCompatibleImage(int width, int height, int transparency)
public static java.awt.image.VolatileImage createCompatibleVolatileImage(int width, int height)
public static java.awt.image.VolatileImage createCompatibleVolatileImage(int width, int height, int transparency)
public static java.awt.Desktop getDesktop()
public static boolean openFolder(java.lang.String folder) throws java.io.IOException
java.io.IOException
public static java.lang.String getProperty(java.lang.String name)
System.getProperty(String)
public static java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
System.getProperty(String, String)
public static java.lang.String setProperty(java.lang.String name, java.lang.String value)
System.setProperty(String, String)
@Deprecated public static int getCtrlMask()
getMenuCtrlMask()
instead.public static int getMenuCtrlMask()
@Deprecated public static int getSystemCtrlMask()
getMenuCtrlMask()
insteadpublic static java.awt.GraphicsEnvironment getLocalGraphicsEnvironment()
public static java.awt.GraphicsDevice getDefaultScreenDevice()
public static java.awt.GraphicsConfiguration getDefaultGraphicsConfiguration()
@Deprecated public static java.awt.GraphicsConfiguration getSystemGraphicsConfiguration()
getDefaultGraphicsConfiguration()
instead.public static java.util.List<java.awt.GraphicsDevice> getScreenDevices()
public static int getScreenDeviceCount()
public static java.awt.GraphicsDevice getScreenDevice(int index)
public static java.util.List<java.awt.GraphicsDevice> getScreenDevices(java.awt.Rectangle region)
public static java.awt.GraphicsDevice getScreenDevice(java.awt.Rectangle region)
null
if given region do not intersect any screen device.public static java.awt.GraphicsDevice getScreenDevice(java.awt.Point position)
null
if given position is not located in any screen device.public static boolean isHeadLess()
public static java.lang.ClassLoader getContextClassLoader()
public static java.lang.ClassLoader getSystemClassLoader()
public static java.awt.BufferCapabilities getSystemBufferCapabilities()
public static java.awt.ImageCapabilities getSystemImageCapabilities()
public static java.awt.image.ColorModel getSystemColorModel()
public static java.awt.image.ColorModel getSystemColorModel(int transparency)
public static java.awt.Rectangle getScreenBounds(java.awt.GraphicsDevice graphicsDevice, boolean removeInsets)
removeInsets
- remove any existing taskbars and menubars from the resultpublic static java.awt.Rectangle getDesktopBounds(boolean removeInsets)
removeInsets
- remove any existing taskbars and menubars from the resultpublic static java.awt.Rectangle getDesktopBounds()
getDesktopBounds(boolean)
public static java.awt.Rectangle getMaximumWindowBounds()
GraphicsEnvironment.getMaximumWindowBounds()
public static java.awt.DisplayMode getSystemDisplayMode()
GraphicsDevice.getDisplayMode()
@Deprecated public static int getAvailableProcessors()
getNumberOfCPUs()
insteadpublic static int getNumberOfCPUs()
public static long getJavaFreeMemory()
public static long getJavaMaxMemory()
@Deprecated public static long getJavaTotalMemory()
getJavaAllocatedMemory()
instead.public static long getJavaAllocatedMemory()
public static long getJavaUsedMemory()
public static long getTotalMemory()
@Deprecated public static long getSystemTotalMemory()
getTotalMemory()
insteadpublic static long getFreeMemory()
@Deprecated public static long getSystemFreeMemory()
getFreeMemory()
insteadpublic static long getProcessCpuTime()
@Deprecated public static long getSystemProcessCpuTime()
getProcessCpuTime()
insteadpublic static int getCpuLoad()
@Deprecated public static int getSystemCpuLoad()
getCpuLoad()
insteadpublic static java.lang.String getUserName()
public static java.lang.String getJavaName()
public static java.lang.String getJavaVersion()
public static double getJavaVersionAsNumber()
public static Version getJavaVersionAsVersion()
public static int getJavaArchDataModel()
public static java.lang.String getOSName()
public static java.lang.String getOSArch()
public static java.lang.String getOSVersion()
public static java.lang.String getOSNameId()
SystemUtil.SYSTEM_WINDOWS
SystemUtil.SYSTEM_MAC_OS
SystemUtil.SYSTEM_UNIX
public static java.lang.String getOSArchIdString()
public static boolean isLinkSupported()
public static boolean is32bits()
public static boolean is64bits()
@Deprecated public static boolean isWindow()
isWindows()
instead.public static boolean isWindows()
public static boolean isMac()
public static boolean isUnix()
public static boolean isWindows64()
public static java.lang.String getTempDirectory()
public static java.lang.String getTempLibraryDirectory()
public static boolean addToJavaLibraryPath(java.lang.String[] directories)
public static void loadLibrary(java.lang.String dir, java.lang.String name)
dir
- directory from where we want to load the native library.name
- name of the library.public static void loadLibrary(java.lang.String pathname)
pathname
- complete path or name of the library we want to load