7

Does Java have any command-line way of specifying a classpath-relative file from which it will load system properties (similar to -D properties)?

Eric
  • 71
  • 1
  • 4
  • Are you looking to specify a file rather that contains several properties rather than listing each property with a `-D`? – bradimus Feb 02 '17 at 18:24
  • Yes, I am looking to specify a file that contains one or more properties. This is for privacy reasons (to avoid seeing the information in a Linux ps or top command), and for brevity of command line. – Eric Feb 02 '17 at 18:39
  • I think you will need to pass the filename in a `-D` and manually load the properties or use a ResourceBundle. See http://stackoverflow.com/questions/22835800/load-config-file-project-properties-at-runtime-via-command-prompt-in-java – bradimus Feb 02 '17 at 18:45
  • ResourceBundle is for internationalization. It should not be used as a general means of loading properties. Just use Properties.load instead. – VGR Feb 02 '17 at 19:03
  • [Envvars _JAVA_OPTIONS or JAVA_TOOL_OPTIONS](https://stackoverflow.com/questions/28327620/difference-between-java-options-java-tool-options-and-java-opts) satisfy what you say are your reasons, but not your question – dave_thompson_085 Oct 12 '18 at 07:39

1 Answers1

2

From Java9, you can use @files option to import a file as command arguments.

See this link.

Dean Xu
  • 4,438
  • 1
  • 17
  • 44