0

How to access command line arguments that is passed as follows?

mvn exec:java -Dexec.mainClass=com.test.App -Dexec.args="-Duserid=10023”

I've tried to receive them by

System.out.println(System.getProperty("userid"));

but it returns null.

aΨVaN
  • 1,104
  • 2
  • 9
  • 18
  • ... what has this code to do with command line arguments? – Stultuske Jun 15 '20 at 06:31
  • @N.M.N: I don't have experience with Maven, but according to [this doc](https://www.mojohaus.org/exec-maven-plugin/java-mojo.html), the name of the property is `exec.args`, which - I suppose - will deliver to you the string _-Duserid=10023_, from which you can then extract the user id. – user1934428 Jun 15 '20 at 08:07
  • Does this answer your question? [how to pass Command line arguments in java](https://stackoverflow.com/questions/29376759/how-to-pass-command-line-arguments-in-java) – Joe Jun 15 '20 at 12:07

0 Answers0