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.
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.
If you are using solaris as the OS, take a look at "pargs" utility. Prints all the info required.
One option I've used in the past to maintain the cross-platform-shine is to set the command line as an environment variable prior to issuing the command.
You might want to look into how
jps
does this. It's a Java program that is able to get the full command line for all Java processes, including full class name of main class and JVM options.The following links may help you get there:
How to get command line arguments for a running process
get command-line of running processes
How to get a list of current open windows/process with Java?
Just as a note:
In Windows you have Process Explorer by Sysinternals that shows you the command line used to open the process. Right click the process and select Properties... You'll see Command Line in the window that is opened.
In Linux/UNIX that should be possible when you get the output of that command (run in a shell)
But that is not portable at all and should therefore not be used in Java...
Some of it is available from the RuntimeMXBean, obtained by calling
ManagementFactory.getRuntimeMXBean()
You can then, for example call
getInputArguments()
The javadocs for which say: