Get command line arguments EXTERNAL basic?

Is there a way in java to get command line arguments that were passed to the program outside of the main function?

I am writing some code that is part of a larger application that I do not control, and I would like to know what command line arguments are without changing the main function.

Note. I saw how to get the JVM arguments and how to get the arguments in the main , but I would like to get it in other parts of our application without storing them in the main function, which I do not control.

+4
source share
1 answer

When starting jvm as follows: java -DmyArgument=myValue -jar your.jar you can get the value myArgument everywhere in your java code with String myArg = System.getProperty("myArgument");

+1
source

All Articles