0

Possible Duplicate:
How to get vm arguments from inside of java application?

I want print the current command line options of a Java process in a log file. Is there an API in Java to request this parameters? I does not means the program arguments that are passed to main. I am interesting on the -X and -D parameters.

Community
  • 1
  • 1
Horcrux7
  • 23,758
  • 21
  • 98
  • 156
  • Those are VM arguments, not program arguments. You might be able to find them in a properties file somewhere, but that's the best I've got, sorry. – BenCole Dec 01 '11 at 14:42

2 Answers2

6

This method will give you all the command line arguments RuntimeMXBean.getInputArguments()

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
1

You can get passed system properties (-D flag) using System.getProperty(String property). If you use this method you must provide property name, if you would like to get all the properties just use System.getProperties().

BizzyDizzy
  • 279
  • 1
  • 4
  • 9