Java 9 has proven that you can get information about Process , but I still don't know how to get CommandLine and process arguments :
Process p = Runtime.getRuntime().exec("notepad.exe E:\\test.txt"); ProcessHandle.Info info = p.toHandle().info(); String[] arguments = info.arguments().orElse(new String[]{}); System.out.println("Arguments : " + arguments.length); System.out.println("Command : " + info.command().orElse("")); System.out.println("CommandLine : " + info.commandLine().orElse(""));
Result:
Arguments : 0 Command : C:\Windows\System32\notepad.exe CommandLine :
But I expect:
Arguments : 1 Command : C:\Windows\System32\notepad.exe CommandLine : C:\Windows\System32\notepad.exe E:\\test.txt
java windows process java-9
Jerry06
source share