0

Need to pass command line args as a key value. As I have 6-7 input arguments of different type and I dont remember the key name if I accept them as a array of string

public void main(String arg[]){}

How can I fetch key value pair without doing any split or anything. Is there a library that supports fetching value of arguments by passing key name.

In what format I should pass? In what format I should fetch data passing key ?

3
  • For example: java -jar myApplication.jar 10 where "10" would be available at arg[0] (remember everything passed is String). You can start here: baeldung.com/java-run-jar-with-arguments. And then take a look to this: stackoverflow.com/questions/7341683/… Commented Jan 15, 2021 at 12:17
  • You could always do it as -Dkey=value where key shows up as a property. Otherwise, do straight command line parsing. There are a number of libs out there. Commented Jan 15, 2021 at 12:18
  • 1
    Your question would be easier to answer if you would edit it and add an example of the command line arguments you’re expecting. Commented Jan 15, 2021 at 14:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.