Java/Development Class/RuntimeMXBean
Версия от 18:01, 31 мая 2010; (обсуждение)
Содержание
- 1 Get Boot path from RuntimeMXBean
- 2 Get ClassPath from RuntimeMXBean
- 3 Get system start time from RuntimeMXBean
- 4 Get the JVM uptime from RuntimeMXBean
- 5 Get the system properties from RuntimeMXBean
- 6 ManagementFactory.getRuntimeMXBean()
- 7 RuntimeMXBean.getBootClassPath()
- 8 RuntimeMXBean.getClassPath()
- 9 RuntimeMXBean.getInputArguments()
- 10 RuntimeMXBean.getStartTime()
- 11 RuntimeMXBean.getSystemProperties()
- 12 RuntimeMXBean.getUptime()
Get Boot path from RuntimeMXBean
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getBootClassPath());
}
}
Get ClassPath from RuntimeMXBean
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getClassPath());
}
}
Get system start time from RuntimeMXBean
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(new Date(mx.getStartTime()));
}
}
Get the JVM uptime from RuntimeMXBean
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getUptime() + " ms");
}
}
Get the system properties from RuntimeMXBean
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getSystemProperties());
}
}
ManagementFactory.getRuntimeMXBean()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getBootClassPath());
}
}
RuntimeMXBean.getBootClassPath()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getBootClassPath());
}
}
RuntimeMXBean.getClassPath()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getBootClassPath());
System.out.println(mx.getClassPath());
System.out.println(mx.getInputArguments());
System.out.println(mx.getSystemProperties());
System.out.println(new Date(mx.getStartTime()));
System.out.println(mx.getUptime() + " ms");
}
}
RuntimeMXBean.getInputArguments()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getInputArguments());
}
}
RuntimeMXBean.getStartTime()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(new Date(mx.getStartTime()));
}
}
RuntimeMXBean.getSystemProperties()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getSystemProperties());
}
}
RuntimeMXBean.getUptime()
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Main {
public static void main(String args[]) throws Exception {
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
System.out.println(mx.getUptime() + " ms");
}
}