I want to pass arguments to a java application but like linux application style.
The main method in java uses an String array for all parameters.
In linux, most applications accepts parameters like: ls -l --color
-l
for to output in list style
--color
is for colorize output
I want to find an piece of code to parse the String array of main method like linux application.
I want to do something like this:
java -jar myapp.jar -d arg1 --arg2
I can make it but I have no time. So, if somebody have some piece of code to do that, better.
String[] argsIt stores Java command-line arguments and is an array of type java.lang.String class.
In Java, args[0] is the first command-line argument to the program, and the name of the program itself is not available.)
String[] args means an array of sequence of characters (Strings) that are passed to the "main" function. This happens when a program is executed. Example when you execute a Java program via the command line: java MyProgram This is just a test.
You have to parse parameters manually or use http://commons.apache.org/cli/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With