command line arguments;


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: command line arguments;

  1. #1
    metasi Guest

    command line arguments;


    Hi everyone,i'm a jnewbie and i need help.
    How can i enable my program to get command line inputs?i tried this

    main(String[] args){
    String = args[0];
    ...
    }
    and I got java.lang.ArrayIndexOutOfBoundsException.

    thank you
    metasi


  2. #2
    UP Guest

    Re: command line arguments;


    Your two line of code says that you need to follow proper java program style.
    basically you pass value of your arguments to a method defined in your class.
    Post more lines from your code and some one sure will help you.


    "metasi" <e.j.developer@juventusfan.com> wrote:
    >
    >Hi everyone,i'm a jnewbie and i need help.
    >How can i enable my program to get command line inputs?i tried this
    >
    >main(String[] args){
    > String = args[0];
    >...
    >}
    >and I got java.lang.ArrayIndexOutOfBoundsException.
    >
    >thank you
    >metasi
    >



  3. #3
    Paul Clapham Guest

    Re: command line arguments;

    When you run your program, you do this:

    java yourClass arg1 arg2 arg3 arg4...

    If you're using a development environment, I don't know, check in the help
    associated with the "Run" option or whatever you are using to run your
    program.

    "metasi" <e.j.developer@juventusfan.com> wrote in message
    news:3add5a6e$1@news.devx.com...
    >
    > Hi everyone,i'm a jnewbie and i need help.
    > How can i enable my program to get command line inputs?i tried this
    >
    > main(String[] args){
    > String = args[0];
    > ..
    > }
    > and I got java.lang.ArrayIndexOutOfBoundsException.
    >
    > thank you
    > metasi
    >




  4. #4
    Justin Campbell Guest

    Re: command line arguments;


    "metasi" <e.j.developer@juventusfan.com> wrote:
    >
    >Hi everyone,i'm a jnewbie and i need help.
    >How can i enable my program to get command line inputs?i tried this
    >
    >main(String[] args){
    > String = args[0];
    >...
    >}
    >and I got java.lang.ArrayIndexOutOfBoundsException.
    >
    >thank you
    >metasi
    >


    From what I can tell (which may very well be wrong with only two lines
    of code to work with), you aren't specifying a first parameter. If you perform
    a .length() on your args array, you'll most likely find it to return 0. You
    should check to be certain that your number of parameters is correct (with
    the .length() method mentioned earlier) before blindly attempting to assign
    their values to variables.

    Good luck!

    - Justin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center