This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes command prompt arguments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "command prompt arguments" Watch "command prompt arguments" New topic

command prompt arguments

Erkki Veps�l�inen

Joined: Feb 10, 2004
Posts: 9
I've made a program that takes arguments from the command prompt. I use the args as conditions for if statements. Now I want to give from 2 to 4 arguments. The problem is that my array gives an Arrayindexoutofboundsexception if I want to give for example only 2 arguments since my if statements contain conditions for args[2] and args[3] aswell.


Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
args.length will tell you the number of arguments.
Remember that args is a totally standard java array
of Strings.


Get a better web browser:<br /><a href="" target="_blank" rel="nofollow"></a>
Erkki Veps�l�inen

Joined: Feb 10, 2004
Posts: 9
Thanks, works out fine

I agree. Here's the link:
subject: command prompt arguments
Similar Threads
need to set the string in command prompt from jtextBox.
NetBeans IDE - how to get arguments from the command line?
system properties
jtips exam2.No.15-args.length?
cannot get the info from disk file