>From the FAQ :
18.(Sect. 8) How do you parse commandline arguments to a Java program?
Perhaps surprisingly, commandline arguments are not encouraged, as
they cause a program not to meet 100% pure Java certification standards. The
reason
is that some systems like MacOS don't normally have a command line or
command-line arguments. Consider using properties instead so that your
programs fit
more naturally into the environment.
If you must use command-line arguments, have them comply with the POSIX
conventions, i.e. they should
use a "-" instead of a "/"
be case sensitive, and
be concatenatable (-pst == -p-s-t).
See
http://java.sun.com/docs/books/tutorial/essential/attributes/_posix.html
If such arguments are used, it should NOT be up to the invocating
application (ie java.exe) to properly parse them. According to the getopts
routine from gnu,
getopts is required to know exactly what the usable parameters are
before it can properly parse them and create argc/argv.
Because of that, it becomes unduly hard for calling programs such as
java.exe to properly parse class arguments by themselves. Instead, they
should create an
argc/argv pair (actually a java specific array dependant on the way in
which the method is called) where the number of elements equals the number
of text
words in the options. Text word means a group of ascii characters
outside of quotation marks, not separated by white space. Once these text
words are
passed to the class, it is up to the class to actually parse them
correctly.
The text words passed to the class can be parsed however the class
author wishes. It is up to the author to correctly parse the options. There
are several
implementations of getopts which perform such parsing, in C, Perl, and
the Java programming language. You will find one at
http://www.urbanophile.com/arenn/hacking/download.html#getopt
> -----Original Message-----
> From: Vidyasagar Jeyakumar [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 14, 2000 10:33 AM
> To: [EMAIL PROTECTED]
> Subject: Command Line Validation in Java
>
>
> Hi,
>
> What is java command which is used for the command
> line validation.Unix call "getopt" is very useful to
> do command line validation.Is there any java command
> equavalent to "getopt" to do command line validation
> in Java.
>
> >java exampleprogram -param1 value1 value2 -param2
> value -param3 value -param4 value1 value2 value3
> -param5 value1 value2 value3
>
> Regards,
> Vidyasagar
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos -- now, 100 FREE prints!
> http://photos.yahoo.com
>
> ==============================================================
> =============
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff EJB-INTEREST". For general help,
> send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".