我不清楚这个问题,但我将解释它,因为你想区分以下2
java -jar fred.jar
和
java 包。主要
这是该计划的大纲线
import sun.jvmstat.monitor.*;
...
HostIdentifier hostId = new HostIdentifier("localhost");
MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(hostId);
Set jvms = monitoredHost.activeVms();
for (Object i: jvms) {
VmIdentifier id = new VmIdentifier("//" + i + "?mode=r");
MonitoredVm vm = monitoredHost.getMonitoredVm(id, 0);
System.out.println(i);
System.out.println("\t main class: " + MonitoredVmUtil.mainClass(vm, false));
System.out.println("\t main args: " + MonitoredVmUtil.mainArgs(vm));
System.out.println("\t jvmArgs: " + MonitoredVmUtil.jvmArgs(vm));
monitoredHost.detach(vm);
}
该调用将返回“”或主类的名称,例如。MonitoredVmUtil.mainClass(vm, false)
jar
Main
您必须使用才能编译和运行。$JAVA_HOME/lib/tools.jar