Here is this simple code from my book it produces error message in netbeans and in compile version (.class) version running through Command prompt.
Error Message
If args[0]
is causing an ArrayIndexOutOfBoundsException
, then you didn't supply any command-line parameters. Test args.length
; if it's 0
, then handle the error.
The args
parameter in a class's main
method is supplied by command line arguments. You are not invoking the jar with any command line args, so the array has no zero element.
You are not passing command line arguments. args[0]
is expecting a command line argument.
IF you are running it from command line try this:
java Intocm 12.0
In eclipse
Run---> Run Configuration--->
Arguments Tab--->
give program arguments-->
apply---> run