本文整理汇总了Java中sun.management.VMManagement类的典型用法代码示例。如果您正苦于以下问题:Java VMManagement类的具体用法?Java VMManagement怎么用?Java VMManagement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VMManagement类属于sun.management包,在下文中一共展示了VMManagement类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProcessId
import sun.management.VMManagement; //导入依赖的package包/类
private static Integer getProcessId() {
try {
// Get the current process id using a reflection hack
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
pid_method.setAccessible(true);
Integer pid = (Integer) pid_method.invoke(mgmt);
return pid;
} catch(Exception ex) {
return null;
}
}
示例2: getProcessId
import sun.management.VMManagement; //导入依赖的package包/类
public int getProcessId()
{
try
{
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
Field jvmField = runtimeMXBean.getClass().getDeclaredField("jvm");
jvmField.setAccessible(true);
VMManagement vmManagement = (VMManagement) jvmField.get(runtimeMXBean);
Method getProcessIdMethod = vmManagement.getClass().getDeclaredMethod("getProcessId");
getProcessIdMethod.setAccessible(true);
return (Integer) getProcessIdMethod.invoke(vmManagement);
}
catch (Exception exception)
{
logger.log(Level.INFO, exception.getMessage(), exception);
}
return -1;
}
示例3: getDiagnosticCommandMBean
import sun.management.VMManagement; //导入依赖的package包/类
static synchronized DiagnosticCommandMBean getDiagnosticCommandMBean() {
VMManagement jvm = ManagementFactoryHelper.getVMManagement();
// Remote Diagnostic Commands may not be supported
if (diagCommandMBean == null && jvm.isRemoteDiagnosticCommandsSupported()) {
diagCommandMBean = new DiagnosticCommandImpl(jvm);
}
return diagCommandMBean;
}
示例4: getPid
import sun.management.VMManagement; //导入依赖的package包/类
/**
* Returns the pid of the current process.
* This fails on systems without process identifiers.
*
* @return the processes pid
* @throws NoSuchFieldException if the JVM does not support the VMManagement class
* @throws IllegalAccessException if the JVM does not support the VMManagement class
* @throws NoSuchMethodException if the JVM does not support pids.
* @throws InvocationTargetException if the JVM does not support pids.
*/
public static int getPid()
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
InvocationTargetException {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (VMManagement) jvm.get(runtime);
Method getProcessId = mgmt.getClass().getDeclaredMethod("getProcessId");
getProcessId.setAccessible(true);
return (Integer) getProcessId.invoke(mgmt);
}
示例5: getOperatingSystemMXBean
import sun.management.VMManagement; //导入依赖的package包/类
public static synchronized OperatingSystemMXBean
getOperatingSystemMXBean(VMManagement jvm) {
if (osMBean == null) {
osMBean = new OperatingSystem(jvm);
}
return (OperatingSystemMXBean) osMBean;
}
示例6: getOperatingSystemMXBean
import sun.management.VMManagement; //导入依赖的package包/类
public static synchronized OperatingSystemMXBean
getOperatingSystemMXBean(VMManagement jvm) {
if (osMBean == null) {
osMBean = new UnixOperatingSystem(jvm);
}
return (OperatingSystemMXBean) osMBean;
}
示例7: getPIDForOracleJVM
import sun.management.VMManagement; //导入依赖的package包/类
protected static int getPIDForOracleJVM() throws Exception {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (VMManagement) jvm.get(runtime);
Method getProcessId = mgmt.getClass().getDeclaredMethod("getProcessId");
getProcessId.setAccessible(true);
return (Integer) getProcessId.invoke(mgmt);
}
示例8: jvmPid
import sun.management.VMManagement; //导入依赖的package包/类
public static final int jvmPid() {
try {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (VMManagement) jvm.get(runtime);
Method pidMethod = mgmt.getClass().getDeclaredMethod("getProcessId");
pidMethod.setAccessible(true);
int pid = (Integer) pidMethod.invoke(mgmt);
return pid;
} catch (Exception e) {
return -1;
}
}
示例9: getProcessId
import sun.management.VMManagement; //导入依赖的package包/类
/**
* Get the process id of the current running Java process
*
* @return Process id
*/
public static int getProcessId() throws Exception {
// Get the current process id using a reflection hack
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
pid_method.setAccessible(true);
int pid = (Integer) pid_method.invoke(mgmt);
return pid;
}
示例10: getProcessId
import sun.management.VMManagement; //导入依赖的package包/类
/**
* Get the process id of the current running Java process
*
* @return Process id
*/
public static int getProcessId() throws Exception {
// Get the current process id using a reflection hack
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
pid_method.setAccessible(true);
int pid = (Integer) pid_method.invoke(mgmt);
return pid;
}
示例11: DiagnosticCommandImpl
import sun.management.VMManagement; //导入依赖的package包/类
DiagnosticCommandImpl(VMManagement jvm) {
this.jvm = jvm;
isSupported = jvm.isRemoteDiagnosticCommandsSupported();
}
示例12: HotSpotThreadImpl
import sun.management.VMManagement; //导入依赖的package包/类
public HotSpotThreadImpl(VMManagement vm) {
super(ManagementFactoryHelper.getVMManagement());
}
示例13: OperatingSystemImpl
import sun.management.VMManagement; //导入依赖的package包/类
OperatingSystemImpl(VMManagement vm) {
super(vm);
}
示例14: getProcessId
import sun.management.VMManagement; //导入依赖的package包/类
public static int getProcessId() throws Exception {
// Get the current process id using a reflection hack
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
pid_method.setAccessible(true);
int pid = (Integer) pid_method.invoke(mgmt);
return pid;
}