Javaプロセスをリストアップする
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.List;
public class ListRunningProcesses {
public static void main(String[] args) {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
List<String> inputArguments = runtimeMxBean.getInputArguments();
System.out.println("JavaプロセスID: " + runtimeMxBean.getName());
System.out.println("Javaプロセスの起動引数:");
for (String arg : inputArguments) {
System.out.println(arg);
}
}
}