How do I get the commandline that started the proc

2019-01-11 19:10发布

From Java, is it possible to get the complete commandline with all arguments that started the application?

System.getEnv() and System.getProperties() do not appear to contain the values.

8条回答
ら.Afraid
2楼-- · 2019-01-11 19:58

Have a look at YAJSW (Yet Another Java Service Wrapper) - it has JNA-based implementations for various OSes (including win32 and linux) that do exactly this so it can grab the commandline for a running process and create a config that wraps it in a service. A bit more info here.

查看更多
ら.Afraid
3楼-- · 2019-01-11 19:59

There is a environment variable %~dp0 which returns the complete path

查看更多
登录 后发表回答