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)?

5
  • Are you looking to specify a file rather that contains several properties rather than listing each property with a -D? Commented Feb 2, 2017 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. Commented Feb 2, 2017 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 stackoverflow.com/questions/22835800/… Commented Feb 2, 2017 at 18:45
  • ResourceBundle is for internationalization. It should not be used as a general means of loading properties. Just use Properties.load instead. Commented Feb 2, 2017 at 19:03
  • Envvars _JAVA_OPTIONS or JAVA_TOOL_OPTIONS satisfy what you say are your reasons, but not your question Commented Oct 12, 2018 at 7:39

1 Answer 1

2

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

See this link.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.